In my roblox game, I am making a shop gui except it does not take away gold. It will give them the extra speed as long as they have enough gold.
player = script.Parent.Parent.Parent.Parent.Parent.Parent Gold = player.leaderstats.Gold.Value cost = 25 script.Parent.MouseButton1Click:connect(function() if Gold>=cost then Gold = Gold - cost player.GuardSpeed.Value = player.GuardSpeed.Value + 1 end end)
Can anyone help?
did you make a part that says leaderboardstat = leaderboardstat - cost
Alright so I went a go at it since I thought that since GuardSpeed is a value shouldn't it be in leaderstats? Also make sure that player actually goes to player. There's quite a number of parents lol.
And cost is declared, just clearing it for everyone.
player = script.Parent.Parent.Parent.Parent.Parent.Parent -- Make sure this is actually leads to the 'player' script.Parent.MouseButton1Click:connect(function() local sGold = player.leaderstats["Gold"] local sGuardSpeed = player["GuardSpeed"] local sCost = 25; if sGold.Value >= sCost then sGold.Value = sGold.Value - sCost sGuardSpeed.Value = sGuardSpeed.Value + 1 print('Purchased speed thingy') else print('Insufficient funds') end end)
EDIT: Removed leaderstat value from GuardSpeed.