✓ Accepted answer
Try using a Local Script.
I'm not the best at animations, but it's probably best to play them from a Local Script.
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local humanoid = char:WaitForChild("Humanoid")
local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local swinganim = handle:WaitForChild("swinganim")
function swing()
local playAnim = humanoid:LoadAnimation(swinganim)
playAnim:Play()
wait(2)
playAnim:Stop()
end
tool.Activated:connect(swing)
Changes I made,
Using WaitForChild is useful, especially when using a Local Script.
This doesn't really change much, but local variables are more useful and I like the way they look.
- I moved all the variables outside the function
This causes less lag and is overall better. I would suggest getting into the habit of doing this yourself.
- I obviously used a Local Script and used Local Player
This was my guess of the problem.
I hope I helped. If you have any questions fill free to ask me.
Good Luck!
If I helped, please don't forget to accept my answer.
1 comment
I fixed a typo.