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

How do I make a NPC animation stop after trigger?

Asked by 3 years ago

I am currently making a roblox horror game and I want to know how I can stop after stepping on the part. This is my code. What I want it to do is once you step on the part, it triggers a animation for a npc. But the thing is, I want the animation to be only one time other than stepping on the part again and the npc animation play again, is there a code where i can make it stop?

local part = script.Parent local NPC = game.Workspace.Scare1 local animationID = 6647562778

part.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then --checks if hit is a player local Animation = Instance.new("Animation",NPC) Animation.AnimationId = "http://www.roblox.com/Asset?ID="..animationID local LoadedAnimation = NPC.Humanoid:LoadAnimation(Animation) LoadedAnimation:Play() end end)

0
Please use a code block CoolBlueJay000 48 — 3y

1 answer

Log in to vote
0
Answered by
imacodr 40
3 years ago

You can use the :Stop function.

https://developer.roblox.com/en-us/api-reference/function/AnimationTrack/Stop

Ad

Answer this question