Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I use debounce correctly in this script?

Asked by 6 years ago
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

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

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)
0
Yeah, negative negative is positivr. ILikeTofuuJoe 1 — 6y
0
i removed not but i can still spam the hell out of it XxLuascriptshandsXx -3 — 6y
0
Ah I missed the nested function let me edit it mattscy 3725 — 6y
Ad

Answer this question