I made several attempts to make an animated tool, but for some reason, the animations that I put in them never run, even if the code executes them.
My last most desperate attempt was to use a RemoteEvent, but it still doesn't work.
LocalScript
1 | local Player = game.Players.LocalPlayer |
2 | local Mouse = Player:GetMouse() |
3 | local Remote = script.Parent:WaitForChild( "RemoteEvent" ) |
4 |
5 | script.Parent.Equipped:Connect( function () |
6 | Mouse.Button 1 Down:Connect( function () |
7 | Remote:FireServer() |
8 | end ) |
9 | end ) |
Script
1 | local Remote = script.Parent:WaitForChild( "RemoteEvent" ) |
2 |
3 | Remote.OnServerEvent:Connect( function (Player) |
4 | local Character = Player.Character |
5 | local Humanoid = Character:WaitForChild( "Humanoid" ) |
6 | local Animation = Humanoid:LoadAnimation(script.Parent.Animation) |
7 |
8 | Animation:Play() |
9 | end ) |
It's not working since the sword isn't part of the humanoid rig. You have to pop an AnimationController into the sword and animate it individually.
Was it the extra space between Humanoid and :LoadAnimation at line 6?
Still, LoadAnimation is deprecated.
About the remote, if the Humanoid that you're trying to play the animation on is controlled by a client, don't do that on the server, do it on a LocalScript, if it is a NPC, then it's fine to do it on the server.
And if that is a tool, you should use the Activated event