hello, im pretty new to scripting and im trying to make a little clicker game right now to learn a bit more, although i ran into a problem that i dont know how to really fix. i have this script, which is a LocalScript inside StarterPlayerScripts but increasing the players stats is not working out, how would i solve this problem else? thanks in advance :)
local itemPrice = {
Id1 = 10,
Id2 = 100,
Id3 = 100
}
for _, button in InShopMenu:GetDescendants() do
if button:IsA("TextButton") then
button.MouseButton1Click:Connect(function()
local itemId = button:GetAttribute("ItemId")
local playerClicks = localPlayer:WaitForChild("leaderstats"):WaitForChild("Clicks")
if playerClicks.Value >= itemPrice[itemId] then
playerClicks.Value -= itemPrice[itemId]
kaChing:Play()
if itemId == "Id1" then
local playerClickPower = localPlayer:WaitForChild("leaderstats"):WaitForChild("ClickPower")
playerClickPower.Value += 1
end
else
notEnoughClicksSound:Play()
end
end)
end
end
** You are now Level 2! **