NPCS spawn ragdolled

Hey guys I noticed that whenever I teleport a character anywhere there is this annoying as frick thing where they get ragdolled for no reason

lIke spawning NPCS and theyre all just ragdolled

Does anyone know how to fix this? so theyre not ragdolled and it ruins player immersion

1 Like

Hello, do they have actual ai right now or are they just models? If they’re just models you can just anchor them! Its not gonna be a long lasting solution, but a solution nonetheless

They are ai rn like pathfinding and stuff

Check if they have GettingUp (i think it’s that) enabled on their humanoids

There is no property called “GettingUp”. It is a humanoid state set by using Humanoid:SetHumanoidStateEnabled(state:Enum,value:boolean).

that’s what i meant lol

`Humanoid:SetHumanoidStateEnabled(state:Enum,value:boolean)

so do I call this? What do I do

Just check the HumanoidStateType applied to the NPC to check which one exactly is doing that, and then perhaps disable that state using Humanoid:SetStateEnabled([statename], false).

Let me ask though, is your ai run in the server or the client? This could also be caused by network ownership.

the ai script under it is in the server – the only acceptable location.

When I say the character ragdolls I mean like when I first spawn them they collapse on the ground and have to get up

What part of what I said have you not understood? Once again, check their states. That is either caused by network ownership or HumanoidStateType, exactly as I said. That is not just a ground collapse being caused by something else.

Also server is not the only acceptable location for an AI and specially pathfinding? Please search about client-based NPCs and how they’re generally more performant for bigger games. That claim makes no sense.

-- what position are you teleporting them to? if you’re using the floor position, they might get ragdolled on teleport due to being clipped into the ground a bit since MoveTo moves the torso to that point. in that case try adding HipHeight + Root.Size.Y * 0.5 to the Y position so that their feet are planted on the ground. if it’s R6 also add + LeftLeg.Size.Y

-- roblox humanoids are incredibly unpredictable to me so i’m just guessing here, i’d need to know more about your scripting otherwise

local function spawnNpc(template: Model, cf: CFrame, parent: Instance)
local npc = template:Clone()
npc.Parent = parent
npc:PivotTo(cf + Vector3.new(0, 2.5, 0))
return npc
end

This is how im doing it

actually this is the code I was doing when spawning my main player

local function stabilizePlayerCharacter(char: Model)
	local hum = char:FindFirstChildOfClass("Humanoid")
	local root = char:FindFirstChild("HumanoidRootPart")
	if not hum or not root then return end

	pcall(function() hum:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false) end)
	pcall(function() hum:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false) end)
	pcall(function() hum:SetStateEnabled(Enum.HumanoidStateType.Physics, false) end)

	root.AssemblyLinearVelocity = Vector3.zero
	root.AssemblyAngularVelocity = Vector3.zero

	hum.Sit = false
	hum.PlatformStand = false

	pcall(function() hum:ChangeState(Enum.HumanoidStateType.Landed) end)
	pcall(function() hum:ChangeState(Enum.HumanoidStateType.Running) end)

	task.delay(0.25, function()
		if hum.Parent then
			pcall(function() hum:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, true) end)
			pcall(function() hum:SetStateEnabled(Enum.HumanoidStateType.FallingDown, true) end)
			pcall(function() hum:SetStateEnabled(Enum.HumanoidStateType.Physics, true) end)
		end
	end)
end

and applying that to my npcs seemed to fix it

By the way I made a final boss NPC thats like a custom model but for some reason it falls through the floor. I set its cancollide and anchor to false cause thats how u get it to animate

is there anything im doing wrong?

-- if all your players are default R6 height then you’d add Vector3.new(0.0, 3.0, 0.0) instead of 2.5, though i doubt that extra half a stud would be causing them to fall over. try placing the PivotTo right before you set the parent to workspace, in general it’s better to finish setting up all your variables before placing them into the world

-- so

local function spawnNpc(template: Model, cf: CFrame, parent: Instance)
    local npc = template:Clone()
    npc:PivotTo(cf + Vector3.new(0.0, 3.0, 0.0))
    npc.Parent = parent
    return npc
end

-- no you should keep CanCollide as true. when you say a custom model do you mean something you made in blender or is it made up of Roblox parts?

its a slug monster thing

but im pretty sure if cancollide is true i cant animate it

its the final boss for my onboarding

-- nah, cancollide doesn’t prevent animations from working. if the spikes are separate parts i’d say they should have cancollide set to false, but the body itself should have collision, or the rootpart if you set it up as a humanoid

alr thansk ill try it. also u gotta admit the onboarding is pretty good

i set cancollide to true but it keeps falling through the ground. what the heck

Oh, sorry!

You need to call it in a script. preferably, parented to the Humanoid itself and then you can just do:
script.Parent:SetStateEnabled(Enum.HumanoidStateType.GettingUp,true)
I was wrong, it’s SetStateEnabled not SetHumanoidStateEnabled.