Animate a rig created by a script

I’ve found a problem on this script, basically i create this dummy with player’s avatar and i’ve tried to animate it, and the result is it just doesnt move at all and the dummy is not anchored i dont understand why it doesnt animate if anyone can modify the script so that the dummy animates too i’d be really grateful

local players = game:GetService("Players")
local player = players.LocalPlayer


local dummy = players:CreateHumanoidModelFromUserId(player.UserId)
dummy.Parent = game.Workspace

local position = Vector3.new(-60.147, 7.236, -84.313)
local orientation = CFrame.Angles(0, math.rad(70), 0)
dummy:SetPrimaryPartCFrame(CFrame.new(position) * orientation)

I just noticed inside the dummy there are the animate scripts of the player idk if i should keep it or delete it through the script

1 Like

well uh, you never do any animations with this code . . . so uh

i know i just wanna know what to add to make that dummy animate through that script

Well you would need to access the humanoids animator, the animator is located under the humanoid, you would then use loadAnimation on the animator.

If you dont know how to do that then here is the documents:

If you want tutorials look up how to load animations for rigs, its the exact same as if you were to animate the player.

I’ll show you what i tried and how the dummy looks on the explorer cause i tried to animate it but it just doesnt move at all here’s the script i used

local players = game:GetService("Players")
local player = players.LocalPlayer


local animationId = "rbxassetid://133832600063763" 


local function playAnimation(dummy)
	local humanoid = dummy:FindFirstChild("Humanoid")
	if humanoid then
		local animation = Instance.new("Animation")
		animation.AnimationId = animationId
		local animTrack = humanoid:LoadAnimation(animation)
		animTrack.Looped = true
		animTrack:Play()
	end
end


local dummy = players:CreateHumanoidModelFromUserId(player.UserId)
dummy.Parent = game.Workspace


local position = Vector3.new(-60.147, 7.236, -84.313)
local orientation = CFrame.Angles(0, math.rad(70), 0) 
dummy:SetPrimaryPartCFrame(CFrame.new(position) * orientation)

playAnimation(dummy)

this is how dummy looks in the explorer:

just HumanoidRootPart is anchored, nothing else and the dummy just doesnt move

ok well I find it easiest and it probably works more often maybe (dont quote me) if the animation that you are going to load is already in the game (meaning you dont have to do the instance.new)

Also dont use :LoadAnimation() on the humanoid, use it on its animator

i’ve modified a bit the script now it works, yeah loadanimation() messed up the animation, ty for the support

1 Like