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

How do I make a Animation Trigger?

Asked by
O_3I 0
6 years ago

I want to make a Animation Trigger for a horror game. So when Player steps on a part, a NPC will do an animation.

Can anyone help me?

2 answers

Log in to vote
0
Answered by
DaR3ka 0
6 years ago

In the same way you use :LoadAnimation() on a player's humanoid, you'd use it on an NPC's humanoid inside a touch event. So once touched, use :LoadAnimation() on the NPC and then just :Play() it.

0
Jumpscare NPC O_3I 0 — 5y
Ad
Log in to vote
0
Answered by
iladoga 129
6 years ago

Here is something that will help you. Replace the animationID variable with your own animation id.

local part = script.Parent
local NPC = game.Workspace.NPC
local animationID = 1338744180

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)

Enjoy and thanks for posting.

0
Press view source, the code is a bit messy. iladoga 129 — 6y
0
Thank you for your help, but when I try pasting the code into my NPC it says "Touched is not a valid member of Model". O_3I 0 — 6y
0
And when I try pasting it in a Part, it says that the animation couldn't load. O_3I 0 — 6y
0
O_3I Try pasting the script in the humanoid of the NPC ReaILazy -9 — 6y

Answer this question