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

Character does not play animation when I click on the brick?

script.Parent.ClickDetector.MouseClick:Connect(function()
	game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
end)

There is a click detector and an animation with an ID inside the part and also the local script.

2 comments

0

LocalScripts doesn't work in Workspace

0

Use a Server Script instead

1 answer

✓ Accepted answer

Since LocalScripts must have a connection to a Client you can't use a LocalScript in Workspace. Change the script to a Server Script (normal Script) and write the following code;

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	player.Character.Humanoid:LoadAnimation(script.Parent.Animation)
end)

When a ClickDetector is clicked. It fires the Event and sends the player who clicked it as an argument. So when we recieve the Event we give the argument a name, in this case player. Then we use our argument, player, and gets the Character as you did before.

1 comment

0

Thank you very much, It did not work at first but I think we both forgot :Play() xD

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