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

How i can delay .Activated event without RemoteEvent?

Asked by 3 years ago

I new in scripting and my english is bad, sorry. I want to make a gun script, but i dont know how to delay a Activated event, so please help me (im using LocalScript)

wait(5)
local plr = game:GetService("Players").LocalPlayer
local hum = plr.Character:WaitForChild("Humanoid")
local tool = script.Parent
local anim = script.Parent.Animation
local animtrack = hum:LoadAnimation(anim)
local sound = game.Workspace.Sounds.shoot

tool.Equipped:Connect(function()
    animtrack:Play()
end)

tool.Unequipped:Connect(function()
    animtrack:Stop()
end)



tool.Activated:Connect(function()
    sound:Play()
    wait(2) --wait isnt delaying
end)

1 answer

Log in to vote
0
Answered by 3 years ago

I found solution

local debounce = false
local sound = game.Workspace.Sounds.shoot

tool.Activated:Connect(function()
    if not debounce == true then
        debounce = true
        sound:Play()
        wait(2)
        debounce = false
    end
end)
Ad

Answer this question