When i click it it always says 0 coins
local click = script.Parent
click.MouseClick:Connect(function(plr)
local coins = plr:WaitForChild("leaderstats").Coins
print(plr,coins.Value)
if coins.Value >= 100 then
print(plr.Name.."bought an item")
coins.Value -= 100
local clone = game:GetService("ServerStorage").Tools:WaitForChild("Item"):Clone()
clone.Parent = plr.Backpack
end
end)
IDoLua
(CantBeBothered)
March 6, 2022, 4:09am
#2
There’s not enough information here to assist you. Please read the guidelines for this category…
Where is it that you should have 100 coins?
Did you ever set Coins.Value to 100?
We can’t assist you with this little snippet.
Oh oops sorry
You need 100 coins or more to buy the item but whatever the value of the coins is it always prints 0 and doesnt work
Also some weird thing is when i tried making it give you coins when you clicked it for testing reasons the value went up?? Idk its confusing
The script I used to raise the value is a simple coins.Value += number and the value is correct when i check my leaderstats value
hallowynl
(hallowui)
March 6, 2022, 4:25am
#4
You didn’t execute the script locally, right?
Its a server script in a click detector
hallowynl
(hallowui)
March 6, 2022, 4:26am
#6
Yes, but you didn’t increase the coins locally, right? The server script only sees the coins as 0 if you did it locally.
2 Likes
Oh god im dum aaaa i was increasing it locally tysm
1 Like