Ok so basically I have this gui where when you get a certain amount of points, you get to rebirth. But somehow, people spam the rebirth button and they get extra rebirths, when they are only supposed to get one. Can anyone help?
Here is a link to a picture of the script: https://gyazo.com/917c67e62665bc4c2b3d2370560f1175
This should work, if you don't want players spamming the rebirth button you need to use debounce
Change local timedelay = 2
to whatever number you want (in seconds)
while true do
because while wait() do is bad practicelocal plr = game.Players.LocalPlayer local debounce = true local timedelay = 2 while true do if debounce == true then debounce = false if (plr.leaderstats.Rebirths.Value * 350) + 350 <= plr.leaderstats.Points.Value then script.Parent.Terrain = "Click to Rebirth" else script.Parent.Terrain = "Rebirth in " ..(plr.leaderstats.Rebirths.Value * 350) + 350 - plr.leaderstats.Points.Value end wait(timedelay) debounce = true end end
You can add a debounce to prevent spamming the function
local Server = game:GetService("Players") local Player = Server.LocalPlayer local debounce = false script.Parent.MouseButton1Click:Connect(function() if debounce then return end ---If debounce = true, then stop progression debounce = true ---Sets debounce to true after clicking the button. Prevents spamming. script.Parent.RebirthEvent:FireServer() wait(5) ---Amount of time to wait before they can click the button again. debounce = false ---Sets debounce to false, allowing the code to run again. end)