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)
You can use the :Stop
function.
https://developer.roblox.com/en-us/api-reference/function/AnimationTrack/Stop