I have a script for a sword that when the animation plays it deals damage to whatever the sword touches.
I’m not getting an error script and there are no error lines. The animation of the sword still plays but it doesn’t deal damage.
Script:
local tool = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local InputService = game:GetService("UserInputService")
local InputType = Enum.UserInputType
local animation = nil
local slashAnimation = nil
tool.Equipped:Connect(function()
animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://7118111810"
slashAnimation = humanoid:LoadAnimation(animation)
end)
s memory.
tool.Unequipped:Connect(function()
animation:Destroy()
slashAnimation = nil
end)
doesnt exist.
local debounce = false
InputService.InputBegan:Connect(function(input, processed)
if input.UserInputType == InputType.MouseButton1 and slashAnimation and not processed then
if debounce then return end
debounce = true
slashAnimation:Play()
local tool = script.Parent
local function onTouch(partOther)
local humanOther = partOther.Parent:FindFirstChild("Humanoid")
if not humanOther then return end
if humanOther.Parent == tool then return end
humanOther:TakeDamage(20)
end
slashAnimation.Stopped:Wait()
debounce = false
end
end)