local debounce = false
local moneybounce = false
game.ReplicatedStorage.place1event.OnServerEvent:Connect(function(player)
if player.leaderstats.Money.Value >= 5 then
if not debounce then
local char = player.Character.Humanoid
debounce = true
if not moneybounce then
moneybounce = true
player.leaderstats.Money.Value = player.leaderstats.Money.Value - 5
moneybounce = false
end
char.WalkSpeed = char.WalkSpeed + 5
print("Purchase Successful!")
debounce = false
end
else
print("Too Poor!")
end
end)
✓ ANSWER ACCEPTED
My shop script for my gui only works once and takes all my money even with a debounce?
2 answers
✓ Accepted answer
after money bounce = true and debounce = true add a wait(time in here) that way they cant click it again the reason it takes all the money is because the function runs several times so i would do
local debounce = false
local moneybounce = false
game.ReplicatedStorage.place1event.OnServerEvent:Connect(function(player)
if player.leaderstats.Money.Value >= 5 then
if not debounce then
local char = player.Character.Humanoid
debounce = true
wait(1)
if not moneybounce then
moneybounce = true
wait(1)
player.leaderstats.Money.Value = player.leaderstats.Money.Value - 5
moneybounce = false
end
char.WalkSpeed = char.WalkSpeed + 5
print("Purchase Successful!")
debounce = false
end
else
print("Too Poor!")
end
end)
You should add a
wait(1)
after the money deduction part. The moneybounce is useless unless there's a wait.
1 comment
0
Thanks!
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Could you please redo the boxes that has the script in it, parts of it aren't in the box.
should be fixed now