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 make a NPC animation stop after trigger?

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)

1 comment

0

Please use a code block

1 answer

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