HumanoidRootPart is upright when ragdolling

hello, whenever a player/npc ragdolls their hrp is always upright and makes it look like they’re floating.

video below

this is my ragdoll code i made

local module = {}

function module:Ragdoll(character : Model)
	local hum = character:FindFirstChildOfClass("Humanoid")
	
	if hum ~= nil then
		for i,v in pairs(character:GetDescendants()) do
			if v:IsA("Motor6D") then
				local a1 = Instance.new("Attachment",v.Part0)
				a1.CFrame = v.C0
				
				local a2 = Instance.new("Attachment",v.Part1)
				a2.CFrame = v.C1
				
				local socket = Instance.new("BallSocketConstraint", v.Part0)
				socket.Name = v.Name
				socket.Attachment0 = a1
				socket.Attachment1 = a2
				socket.Restitution = 1
				socket.LimitsEnabled = true
				socket.TwistLimitsEnabled = true


				
				v.Enabled = false
			elseif v:IsA("BasePart") then
				if v.Name ~= "Torso" and v.Name ~= "HumanoidRootPart" then
					v.CanCollide = true
				end
				v.CollisionGroup = "Ragdoll"
			end
		end
		
		hum:ChangeState(Enum.HumanoidStateType.PlatformStanding)
		hum:SetStateEnabled(Enum.HumanoidStateType.GettingUp,false)
		hum.RootPart.CanCollide = false
		
	end
end

function module:Unragdoll(character : Model)
	local hum = character:FindFirstChildOfClass("Humanoid")

	if hum ~= nil then
		hum.PlatformStand = false
		hum.RootPart.CanCollide = true		
		hum:ChangeState(Enum.HumanoidStateType.GettingUp)
		for i,v in pairs(character:GetDescendants()) do
			if v:IsA("Motor6D") then
				v.Enabled = true
			elseif v:IsA("BallSocketConstraint") then
				v:Destroy()
			elseif v:IsA("Attachment") then
				v:Destroy()
			elseif v:IsA("BasePart") then
				v.CanCollide = false
				v.CollisionGroup = "Default"
			end
		end
	end
end


return module

i’ve tried different humanoid states, setting the HRP CanCollide to false, i just cant get it fixed. any help would be appreciated :slight_smile:

nevermind, i have fixed it. you’re supposed to change humanoidstatetypes on the client instead of the server.