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

It won't play the animation for some reason?

local player = game.Players.LocalPlayer
game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		local animation = game.StarterPack.LocalScript.Blue
		local character = plr.Character
		local hum = character.Humanoid
		if msg == "/e dab" then
			local track = hum:LoadAnimation(animation)
			track:Play()
		end
	end)
end)

3 comments

0

Local scripts can not play animations (assuming your game is filtering enabled), that's the only reason I can think of.

0

Local scripts can play animations. Their actually supposed to be used in local scripts. ^

0

Check anim's Priority

2 answers

It's because playeradded have some problems being used on the client side. I fixed your script, it should work now. Also, animations are able to work on the local side as the player controls all their movements.

local player = game.Players.LocalPlayer
    player.Chatted:Connect(function(msg)
        local animation = game.StarterPack.LocalScript.Blue
        local character = player.Character
        local hum = character.Humanoid
        if msg == "/e dab" then
            local track = hum:LoadAnimation(animation)
            track:Play()
     end
end)

2 comments

0

Playeradded can be used in the client side but it has some issues with studio. Check wiki.

0

Weird, I've never heard of that. But I updated my answer.

First of all, I would like to say that there is no error in your script. Playeradded can sometimes have issues in the client side, but it works if you know how. Also I believe that the chatted event can be used better in a server script. Copy your code onto a script in serverscriptservice and delete the first line: “local player = game.Players.LocalPlayer”. With the player parameter from playeradded event, you should get the character. From there you should be good. Any problems, don’t hesitate to comment back. Also it’s recommended to use animations from client side so you could fire the client and play animation from the client. Thanks!

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