I'm currently making a game, and the script I've made for a melee weapon is able to be spammed. I want to add a "wait (0.94)" so that once the melee sound finishes playing, the melee weapon is able to be used again. Does anybody know how I can do this?
Here is the script I'm using:
local tool = script.Parent
local canDamage = false
local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if not humanoid then
return
end
if humanoid.Parent ~= tool.Parent and canDamage then
humanoid:TakeDamage(15)
else
return
end
canDamage = false
end
local function slash()
local str = Instance.new("StringValue")
str.Name = "toolanim"
str.Value = "Slash"
str.Parent = tool
canDamage = true
end
tool.Activated:Connect(slash)
tool.Handle.Touched:Connect(onTouch)

1 comment
There is an entire article on how to use debounces: https://developer.roblox.com/en-us/articles/Debounce