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

help with running animations by clicking a part in the workspace?

hello once again i am asking for help. i am trying to get a custom animation to run when the player clicks a part so far i have not been able to get anything to work. could someone help me?

3 comments

0

Can you paste your script here?

0

game.Workspace.Hello.ClickDetector.MouseClick:Connect(function(Player) local animation = Instance.new(“Animation”) animation.AnimationId = “http://www.roblox.com/Asset?ID=04916278158 local loadedAnimation = game.Workspace[player.Name].Humanoid:LoadAnimation(animation) loadedAnimation:Play() end) 

0

I made an answer. Check it out and try it.

1 answer

✓ Accepted answer

Looks like you forgot the other " at the end of the AnimationId property string. Also, I would use the built-in property, "Character", which is automatically in the player.

workspace.Hello.ClickDetector.MouseClick:Connect(function(player)
	local animation = Instance.new("Animation")
	animation.AnimationId = “rbxassetid://04916278158"
	
	local loadedAnimation = player.Character.Humanoid:LoadAnimation(animation)
	loadedAnimation:Play()
end)

2 comments

0

thank you this worked but for some reason the animation plays 3 times

0

for anyone who was interested i solved with a wait() after the play

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