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

How do I play an animation on a player, when he touches the part?

I tried to make a script, but for some reason it doesn't work. I don't know why, so I need help.

local localplayer = players.LocalPlayer
local animation = localplayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)

script.Parent.Touched:Connect(function(hit)
	animation:Play()
end)

2 comments

0

Is It A Local Script Or A normal Script?

0

It's normal script

1 answer

I am unsure if this works (I'm Still New To Roblox Studio) But Try this create a folder with all the animation in it under the script

local animation = script:WaitForChild("Animations")
	local Character = player.Character
	local Humanoid = Character:WaitForChild("Humanoid")
local animation = Humanoid:LoadAnimation(Animations:WaitForChild("animation"))

script.Parent.Touched;Connect(Function(Hit))
	animation:Play()
end

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