Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I use debounce correctly in this script?

anime = script.Parent.name.Value
local gain = game.ReplicatedStorage.Remotes.GainPoint
local Power = game.Players.LocalPlayer.leaderstats.Power
local debounce = false



script.Parent.Selected:connect(function(m)
	
	if not debounce == false then
	debounce = true
	

	m.Button1Down:connect(function()
		 hum = game.Players.LocalPlayer.Character.Humanoid
		 anim_feet = hum:LoadAnimation(script.Parent.Animation)
		current = anim_feet
		current:Play()
		
			

		game.ReplicatedStorage.Remotes.GainPoint:FireServer()
		
	wait(3)
		debounce = false

		
		end)
	end
end)

-- how do i use debounce correctly? no errors. my debounce attempt stops the script from working entirely what am i doing wrong?

1 answer

✓ Accepted answer

Since the line

if not debounce == false then

is the equivalent to checking if debounce is true, simply remove the not and it should work.

anime = script.Parent.name.Value
local gain = game.ReplicatedStorage.Remotes.GainPoint
local Power = game.Players.LocalPlayer.leaderstats.Power
local debounce = false
local selected

   game.Players.LocalPlayer:GetMouse().Button1Down:connect(function()
if debounce == false and selected then
    debounce = true
         hum = game.Players.LocalPlayer.Character.Humanoid
         anim_feet = hum:LoadAnimation(script.Parent.Animation)
        current = anim_feet
        current:Play()



        game.ReplicatedStorage.Remotes.GainPoint:FireServer()

    wait(3)
        debounce = false


        end
    end)

script.Parent.Selected:connect(function()
selected = true

end)

3 comments

0

Yeah, negative negative is positivr.

0

i removed not but i can still spam the hell out of it

0

Ah I missed the nested function let me edit it

This discussion is preserved as it was. New answers, comments, and votes are closed.