I'm trying to make an animation for a tool that I made. I've followed the wiki and googled around, but nothing I do seems to work!
Here's the code -
local tool = script.Parent local player = game.Players.LocalPlayer local hum = player.Character:WaitForChild("Humanoid") --setting variables local swing = tool.swinginganim --setting animation variable local AnimTrack = hum:LoadAnimation(swing) --loading animation local canplay = true local swinging = false local hitnum = 0 script.Parent.Equipped:connect(function(mouse) mouse.Button1Down:connect(function(hitting) if canplay == true then canplay = false swinging = true AnimTrack:Play() --playing the animation wait(2) canplay = true swinging = false hitnum = 0 print 'done' end end) end) tool.Handle.Touched:connect(function(touch) --giving resources when you hit if swinging == true and hitnum == 0 then if touch.Name == "resource" then print 'found resource node' hitnum = hitnum+ 1 wait(.75) player.iron.Value = player.iron.Value + 1 end end end)
Thanks for reading.