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

How i can delay .Activated event without RemoteEvent?

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

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)

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