How do I make animations play in my custom rig?

My team is trying to make a game similar to Piggy where a player gets chosen as the monster and has to kill all the other players. The problem we’re facing is that when we set a players character as piggy when the round starts, the character doesn’t animate, instead it just plays no animation while moving or jumping. There’s an animate script inside the character that works fine when we set the piggy character as a “StarterCharacter”, but we only want one player to be piggy, so we can’t do that. Has anyone else come across this problem and knows how to solve it?

-- server

local function morphPlayers()
	for i,v in pairs(game.Players:GetPlayers()) do
		local char = v.Character or v.CharacterAdded:Wait()
		local morph
		
		char.STARTER_CHARACTER.Parent = morph
		
		if v.UserId == monster then
			morph = flappy_morphs.Default:Clone()
			morph.Name = char.Name
			morph.Parent = workspace
			v.Character = morph
			char:Destroy()
			setMorphCam_event:FireClient(v,morph)
			
		else
			morph = kid_morph:Clone()
			morph.Name = char.Name
			morph.Parent = workspace
			v.Character = morph
			char:Destroy()
			setMorphCam_event:FireClient(v,morph)
		end
	end
end

-- client

setMorphCam_event.OnClientEvent:Connect(function(morph)
	local char = plr.Character or plr.CharacterAdded:Wait()
	local hum = char.Humanoid
	
	local morph_hum = morph:WaitForChild("Humanoid")
	if not morph_hum then print("Humanoid of morph not found") return end
	workspace.CurrentCamera.CameraSubject = morph.Head
	workspace.CurrentCamera.CameraType = Enum.CameraType.Follow
end)

6 Likes

Have you rigged your model using Motor6Ds?

3 Likes

Yeah, the model was rigged with motor6Ds. The animations and everything play fine when we make it the StarterCharacter, but we only want one piggy character, so we have to set the player as piggy in the code and for some reason that stops it from animating.

2 Likes

I see what you’re saying.

You could try instantiating a new instance of the Animate script in the character model that you’re cloning, and then enable it. You would want to do this client-sided, and the script should be a LocalScript as it’s dealing with animation.

Not sure if you tried that, sort of just skimmed over your code.

4 Likes

Try adding a Animator into the humanoid in a Server Script

2 Likes

Thanks the animations are loading now! One problem, when the morph spawns in, its legs go through the ground and it seems to rest on its humanoid root part instead of on its feet. To actually ‘stand’ on the ground I have to glide the morph onto some kind of ledge or slope so the physics can work again.

image

Any way I can fix this?

2 Likes

It looks like a HipHeight issue.

I think by default the HipHeight of the Humanoid should be set to around 1.5 or so; you can find out the default HipHeight by playing in Studio test then seeing what the property is set to in your character.

2 Likes

the hip height is fine and after maneuvering the character you can get the physics to off the ground and the rig stands and moves on its feet. The problem is that 9 times out of 10 it spawns in and the rig stands on its root part like it does above. I have no clue why this happens or how to fix it.

I realize this thread is very old, but for those who run into the aforementioned problem with HipHeight, set the AutomaticScalingEnabled property of the rig’s Humanoid to false:
image
In my case, when this property was true, the HipHeight was being overridden to -1, causing the same undesired behavior.

7 Likes