To clarify, I want to know how I can STOP it from dealing damage when the tool is NOT moving, and how it CAN deal damage ONLY when the tool is moving. I don't want to to be like the classic roblox sword.
I have this script here, I need to know what I can add to it that will allow the tool to deal damage ONLY when its animation plays..
Script:
local Tool = script.Parent local Animation = Tool.Animation local activeCooldown = false local cooldownTime = 3 Tool.Activated:Connect(function() if (activeCooldown) then return else activeCooldown = true local Character = Tool.Parent local Humanoid = Character.Humanoid local AnimationTrack = Humanoid:LoadAnimation(Animation) cooldownTime = AnimationTrack.Length AnimationTrack:Play() wait(3) activeCooldown = false end end)
thanks, needed to revise to make it a bit more understandable lol
If you want a sword then, Here you go...
local Tool = script.Parent local Animation = Tool.Animation local activeCooldown = false local cooldownTime = 3 local Blade = script.Parent.Handle -- HitPart local Damage = 10 -- Damage Tool.Activated:Connect(function() if (activeCooldown) then return else activeCooldown = true local Character = Tool.Parent local Humanoid = Character.Humanoid local AnimationTrack = Humanoid:LoadAnimation(Animation) cooldownTime = AnimationTrack.Length AnimationTrack:Play() wait(3) activeCooldown = false end end) Blade.Touched:Connect(function(Hit) wait(1) if activeCooldown == true and Hit.Parent:FindFirstChild("Humanoid") then Hit.Parent:FindFirstChild("Humanoid").Health -= Damage else return end end)
Hope It Helps!