This is done by a RemoteEvent to an animation script in StarterCharacterScripts. It’s also having a detection between NPC’s and PC’s.
PC’s are working completely.
NPC’s aren’t animating, sadly. This is my code:
local arrestAnimation = Instance.new("Animation")
arrestAnimation.AnimationId = "rbxassetid://4178326828"
--[
-- Arrestation script activator with some other code here. Not relevant to the topic.
--]
arrestAnimationTrack = Humanoid:LoadAnimation(arrestAnimation)
arrestAnimationTrack:Play()
It doesn’t run, not even on scriptless rigs. The animation is set on looping at the editor.
How would I animate NPC’s properly using the Humanoid?
i… don’t quite get it ? The title mention you want to stop it,
But what you’re telling us with your code is tthat the NPC is not even playing the animation ?
not even on “normal rigs”
and your final question is
so i’m utterly confused, but you can just do :Stop() as long you have the animation loaded as a variable, however, if you don’t, you can eventually check & access all animations on a Humanoid with the following :
local AnimationTracks = Hit.Parent.Humanoid:GetPlayingAnimationTracks()
for i, track in pairs (AnimationTracks) do
if track == "AnimationName" then
track:Stop()
break
end
end
I’d apologize for my writing which could lead into confusion. My code is indeed not working properly. I emphasized stopping an animation, which I shouldn’t have done.
To make it clear:
I want to let a NPC animate using the function Humanoid:LoadAnimation(). Roblox is only providing information about animating NPC’s using an AnimationController.
You said you used a AnimationController, according to
You don’t load via Humanoid, but AnimationController
local humanoid = npcModel:FindFirstChildOfClass("Humanoid")
humanoid:Destroy()
local animationController = Instance.new("AnimationController", npcModel)
-- Create and load an animation
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset/?id=507771019" -- Roblox dance emote
local animationTrack = animationController:LoadAnimation(animation)
-- Play the animation
animationTrack:Play()
I see that the code given in your post is an animation that you created (Instance.new(“Animation”)? Have you placed it or cloned it into the destination desired?