Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can LocalScripts call animations to play?

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

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.