this script works fine if I donot add candamage and slash . But i need those can anybody help why aint this script work if i add cooldown .
local tool = script.Parent
local Anim ={tool.Animation,tool.AnimationIdle}
local tool = script.Parent
local candamage = false
local slash = true
local function ontouch(otherpart)
local character = otherpart.Parent
local humanoid = character:FindFirstChild(“Humanoid”)
if not humanoid then return end
if humanoid.Parent~=otherpart.Parent and candamage==true then
print("now we can damage")
humanoid.Health=humanoid.Health-30
candamage=false
end
end
local track
tool.Equipped:Connect(function()
track = script.Parent.Parent.Humanoid:LoadAnimation(Anim[2])
track:Play()
end)
tool.Unequipped:Connect(function()
track:Stop()
end)
local function slash()
if slash==true then
print(“canslash”)
slash = false
local slash = script.Parent.Parent.Humanoid:LoadAnimation(Anim[1])
slash:Play()
candamage=true
wait(0.1)
slash=true
end
end
tool.Activated:Connect(function(slash)
tool.Blade.Touched:Connect(function(otherpart)
ontouch(otherpart)
end)
end)
