Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Revgery 15
2 years ago

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)
0
Is It A Local Script Or A normal Script? Verbalase_notreal 23 — 2y
0
It's normal script Revgery 15 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

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
Ad

Answer this question