Ad
Log in to vote
0

I'm trying to make an animated sword, but its animation never runs, why?

Asked by 3 days ago
Edited 3 days ago

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

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Remote = script.Parent:WaitForChild("RemoteEvent")

script.Parent.Equipped:Connect(function()
    Mouse.Button1Down:Connect(function()
        Remote:FireServer()
    end)
end)

Script

local Remote = script.Parent:WaitForChild("RemoteEvent")

Remote.OnServerEvent:Connect(function(Player)
    local Character = Player.Character
    local Humanoid = Character:WaitForChild("Humanoid")
    local Animation = Humanoid:LoadAnimation(script.Parent.Animation)

    Animation:Play()
end)

2 answers

Log in to vote
0
Answered by 3 days ago

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.

0
Thank you genilsonotavio 114 — 3d
Ad
Log in to vote
0
Answered by 3 days ago
Edited 3 days ago

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

Answer this question