Using Blender Animation

Hello I’m working with an animation, I’m using it inside an animal created and rigged with bones in blender and then imported in studio, I watched a video to do it, but I have a problem, I want the animal to move, and I always used Humanoid to load the anim and to make it woander, but this time that I imported the model (FBX) with 3D Importer, if I put inside the model the Humanoid, the animation doesn’t run , but I need Humanoid to move the animal random so anyone has an idea to make the animal wander and to solve the animation issue ?

local Model = script.Parent
local Humanoid = Model.Humanoid
local Torso = Model.Body

local anim = script.Animation
local AnimController = script.Parent.AnimationController
local LoadAnim = AnimController:LoadAnimation(anim)

LoadAnim:Play()

local Sound = script.Parent.Body.Sound

while true do
	wait(math.random(3,5))
	LoadAnim:Play()
	Sound:Play()
	Humanoid:MoveTo(Torso.Position + Vector3.new(math.random(-3, 3), 0, math.random(-3, 3)))
	Humanoid.MoveToFinished:Connect(function()
		LoadAnim:Stop()
	end)
end

immagine

1 Like

i think you need to use instance.new and import a new animation with that
i would try this

I have already done this and unfortunately it didn’t run …

Have you parented the Animator to the Humanoid? That’s probably the reason why it’s not playing, you’re using two different instances that would need the Animator. If it’s a humanoid, as in it’s supposed to be structured as an actual NPC, stick with the Humanoid instance. The AnimationController is for those that doesn’t have a HumanoidRootPart, since that’s required for the Humanodi to work.

TL;DR: Just place the Animator inside of the Humanoid and see if that works.

Delete the AnimationController and use Humanoid.Animator in the script instead.

1 Like

okay I tested it and it works, but it moves around without wait the time, cause in the script there is

wait(math.random(3,5))
	LoadAnim:Play()
	Sound:Play()
	Humanoid:MoveTo(Torso.Position + Vector3.new(math.random(-3, 3), 0, math.random(-3, 3)))
	Humanoid.MoveToFinished:Connect(function()
		LoadAnim:Stop()

that teorically makes the pet move to a position, and then after 3 seconds , it starts again but if I use a pet with bones, it wander crazy…

New Code

local Walk = 12130860336

local Humanoid = script.Parent:WaitForChild("Humanoid", 1)
local Torso = script.Parent.Body

local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://"..Walk
local WalkAnim = Humanoid:LoadAnimation(Animation)


--local Sound = script.Parent.Body.Sound

while true do
	wait(math.random(3,5))
	WalkAnim:Play()
	--Sound:Play()
	Humanoid:MoveTo(Torso.Position + Vector3.new(math.random(-3, 3), 0, math.random(-3, 3)))
	Humanoid.MoveToFinished:Connect(function()
		WalkAnim:Stop()
	end)
end

immagine

Connect() attaches a listener to the event, and runs the code inside every time the event fires. But attaching the listener doesn’t yield the code, and also the code here adds another listener for each loop iteration.
You can fix that by replacing that part of code from:

Humanoid.MoveToFinished:Connect(function()
	WalkAnim:Stop()
end)

to

Humanoid.MoveToFinished:Wait()
WalkAnim:Stop()

Wait() yields script execution until the event fires.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.