Hello, I want to make an entity for my game and I was importing a skinned mesh for it. But I am having trouble playing an Idle animation for it as it isn’t loading in. I’ve looked up other resources but it doesn’t seem to work, any help?
My entity:
Code:
--Variable--
local Entity = script.Parent
local hum = Entity.Humanoid
local humrp = Entity.HumanoidRootPart
local Animator = hum.Animator
local IdleAnim = script.Animations.Idle
Animator:LoadAnimation(IdleAnim):Play()
Yes I have checked the animation ID it is correct, yes the Animator is in the humanoid, everything is correctly placed. The animation just won’t play, but the script IS telling me it is playing. But it won’t visually play it.
I’m not sure if this is the right topic since this is mainly a scripting issue, but hopefully someone is able to help me as I’ve been stuck on this for awhile now.
Is this a Server Script? If yes, try to view if the animation is playing in Server View.
If the animation isn’t even playing in Server View.
Try this
--Variable--
local Entity = script.Parent
local hum = Entity:FindFirstChildWhichIsA("Humanoid")
local humrp = Entity.HumanoidRootPart
local Animator = hum.Animator
local IdleAnim = script.Animations.Idle
hum:LoadAnimation(IdleAnim):Play()
I’ve been looking into AnimationControllers curious to see if it would have anything to do with my problem. I’ve also been checking if the animation is even playing.
Animator:GetPlayingAnimationTracks()
But nothing is popping up, if anyone knows how to play animation on a skinned mesh like mine, let me know. Let me also send it’s model children/descendants to see if I did any placements wrong.
Yes, I have tried it from both server and local script, I’m currently experimenting with many different things to see if I can get it just right to play the animation.
Ok I somehow fixed it, it is working. I fixed it by removing the AnimationController, adding a normal script, and inside the script creating a new animation object with
Instance.new("Animation")
Then adding my AnimationId to it
local animationId = "rbxassetid://9176507064" -- change this to your animation id
local animation = Instance.new("Animation")
animation.AnimationId = animationId
local hum = script.Parent.Humanoid
local animator = hum.Animator
local animationTrack = animator:LoadAnimation(animation)
-- call this function to play the animation
animationTrack:Play()
I’m not sure if this has anything to do with the Animation object or if Skinned Meshes can’t play animations through an animation object. But weird feature, and I honestly dislike my life at this point.