Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can LocalScripts call animations to play?

Asked by 4 years ago

Hi, I'm making a game but my sword script (which is a localscript) is not playing the animation.

tool.Activated:Connect(function()
    script.Attack:Play()
end)

this is not giving any errors or warnings, but the animation is not playing either.

Do I need to use a remoteevent and then call it when player clicks to play the animation?

Thanks

1 answer

Log in to vote
1
Answered by 4 years ago

You can definitely load and play animations from the client (character animations). Your problem might be script.Attack being an Animation and not an AnimationTrack. All animations have to be loaded with the player’s humanoid, after which they can be played.

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

local Animation = script.Attack
Animation = Character.Humanoid:LoadAnimation(Animation)

tool.Activated:Connect(function()
    Animation:Play()
end)
Ad

Answer this question