how would i use debounce in this situtation? ive looked on the wiki and it doesnt make much sense to me. Also how would i be able to make it so if someone clicked they would have to wait a few seconds before they can click again? i dont think im doing it right
local mouse = game.Players.LocalPlayer:GetMouse() local clicks = 0 wait(5) mouse.Button1Down:connect(function() clicks = clicks + 1 if clicks == 3 then for i = 1,1 do local Leaderstats = game.Players.LocalPlayer.leaderstats:findFirstChild("Strength") if Leaderstats ~= nil then for i = 1,1 do Leaderstats.Value = Leaderstats.Value + 1 wait(5) clicks = 0 end end end end end end)
pss, your script looks messy cause your not using indents right ;p
Ok so to make a debounce we are going to create a bool variable outside this mess, then with they click check if it is true, if so make it false, at the end of the click event we wait a few seconds then make it true again.
local mouse = game.Players.LocalPlayer:GetMouse() local clicks = 0 local d = true wait(5) mouse.Button1Down:connect(function() if d==true then d=false --debounce clicks = clicks + 1 if clicks == 3 then for i = 1,1 do local Leaderstats = game.Players.LocalPlayer.leaderstats:findFirstChild("Strength") if Leaderstats ~= nil then for i = 1,1 do Leaderstats.Value = Leaderstats.Value + 1 clicks = 0 end end end end end wait(5) --debounce wait d=true --change back end)