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

Why don't NPC animations work with FilteringEnabled?

Asked by
Dad_Bot 34
6 years ago

I have a script that works fine for one of my NPC characters when FilteringEnabled is not on. All the animations are played correctly and he looks normal. The NPC character is copied from ReplicatedStorage to Workspace before the walk animation is supposed to be played. When FilteringEnabled is turned on no animations can be seen, he just hovers over to the spot with no movement. Let me know if you need any further clarifications.

0
Could we take a look at the script that loads the animation into the NPC. I myself have animated NPC's that work fine in FE. Scaii_0 145 — 6y
1
It is the regular player Animate script except in a ServerScript rather than local. Dad_Bot 34 — 6y

1 answer

Log in to vote
0
Answered by
Scaii_0 145
6 years ago

My way of animating an NPC in FE is this way:

First have a normal Script in the character In that Script insert an animation with the animation ID you want In the Script

First we're going to make sure we have something to play the animation from.

local char = script.Parent
local humanoid = char:WaitForChild('Humanoid')

This part sets the local char as the script's parent but you can change it if you have other ways of getting to the NPC. It then waits for a humanoid in the character.

Next, if we find the humanoid, we load the animation

local char = script.Parent
local humanoid = char:WaitForChild('Humanoid')
local anim = humanoid:LoadAnimation(script.Animation) 

Straight forward. The animation's parent should be this script but then again you may change it for other ways of accessing it.

Finally we make the animation play.

local char = script.Parent
local humanoid = char:WaitForChild('Humanoid')
local anim = humanoid:LoadAnimation(script.Animation) 


if char ~= nil then 
    anim:Play()
end

So the script checks if the character exists. If so, it will then play the animation we loaded earlier and then end.

Ad

Answer this question