I have this local script inside a tool, it's supposed to play animation once player clicks their mouse with the tool equipped. For some reason nothing happens and I get no errors. Please somebody help me I tried lots of methods from internet and none worked.
Code:
local tool = script.Parent
tool.Activated:Connect(function()
if tool.Parent:WaitForChild("Humanoid"):WaitForChild("Animator") == nil then
local animator = Instance.new("Animator", script.Parent.Parent:WaitForChild("Humanoid"))
end
local load = script.Parent.Parent:WaitForChild("Humanoid"):LoadAnimation(tool:WaitForChild("KatanaAnimation"))
wait(1)
load:Play()
end)
tool.Handle.Touched:Connect(function(opart)
if opart.Parent.Humanoid ~= nil then
if opart.Parent.Name ~= script.Parent.Parent.Name then
opart.Parent.Humanoid.Health = opart.Parent.Humanoid.Health - 10
end
end
end)
Thanks for any responses :)