Ragdoll works on NPCs but not players?

The script inside the player, and the script inside the NPCs are identical

When an NPC gets ragdolled it works perfectly, but when a player gets ragdolled they float above the ground?

It was working perfectly before the update last night.

Here is a video showing the issue.

Here is hierarchy
(This is in StarterCharacterScripts)
image

Here is the ragdoll script (Identical to NPC)

local globals = require(game.ReplicatedStorage:WaitForChild("Modules"):WaitForChild("Globals"))

--------------------

local RagdolledVal = script:WaitForChild("Ragdolled")
local CanRagdoll = script:WaitForChild("CanRagdoll")

local Humanoid = script.Parent:FindFirstChildWhichIsA("Humanoid")
local HumanoidRootPart: BasePart = Humanoid.RootPart

local ragJointsCreated = false

local ogCC
local ogOwner

if Humanoid then
	Humanoid.RequiresNeck = false
	Humanoid.BreakJointsOnDeath = false

	RagdolledVal.Changed:Connect(function()
		if RagdolledVal.Value == true then
			if CanRagdoll.Value then
				ogCC = HumanoidRootPart.CanCollide
				ogOwner = HumanoidRootPart:GetNetworkOwnershipAuto() or HumanoidRootPart:GetNetworkOwner()
				HumanoidRootPart:SetNetworkOwner(nil)
				HumanoidRootPart:SetNetworkOwnershipAuto(false)
				
				HumanoidRootPart.CanCollide = true

				Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
				local animator = globals.getAnimator(Humanoid) -- Gets the animator, no effect on script
                if animator then
				    local anims = animator:GetPlayingAnimationTracks()
				    for _, a in pairs(anims) do
					    a:Stop()
				    end
                end

				if not ragJointsCreated then
					for _, motor: Motor6D in pairs(script.Parent:GetDescendants()) do
						if motor:IsA("Motor6D") then
							motor.Enabled = false

							local newBSC = Instance.new("BallSocketConstraint", motor.Parent)
							local a0 = Instance.new("Attachment", motor.Part0)
							local a1 = Instance.new("Attachment", motor.Part1)

							a0.CFrame = motor.C0
							a1.CFrame = motor.C1

							newBSC.Attachment0 = a0
							newBSC.Attachment1 = a1

							newBSC.Name = motor.Name .. ":RagdollConstraint"

							newBSC.LimitsEnabled = true
							newBSC.TwistLimitsEnabled = true

							newBSC.Enabled = true
						end
					end

					ragJointsCreated = true
				else
					for _, motor: Motor6D in pairs(script.Parent:GetDescendants()) do
						if motor:IsA("Motor6D") then
							local BSC = motor.Parent:FindFirstChild(motor.Name .. ":RagdollConstraint")

							BSC.Enabled = true
							motor.Enabled = false
						end
					end
				end
			else
				RagdolledVal.Value = false
			end
		else
			if CanRagdoll.Value then
				HumanoidRootPart.CanCollide = ogCC

				Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
				for _, motor: Motor6D in pairs(script.Parent:GetDescendants()) do
					if motor:IsA("Motor6D") then
						local BSC = motor.Parent:FindFirstChild(motor.Name .. ":RagdollConstraint")

						if BSC then
							BSC.Enabled = false
							motor.Enabled = true
						end
					end
				end
				
				if HumanoidRootPart.Parent and HumanoidRootPart.Parent:IsDescendantOf(game.Workspace) then
					if ogOwner == true then
						HumanoidRootPart:SetNetworkOwnershipAuto()
					else
						HumanoidRootPart:SetNetworkOwner(ogOwner)
					end
				end
			end
		end
	end)
end

and this is the ragdoll function inside ‘globals’

function globals.setRagdolled(Humanoid : Humanoid, Ragdolled : boolean)
	if Ragdolled == nil then
		Ragdolled = not Ragdolled
		ragdollStates[Humanoid] = not ragdollStates[Humanoid]
	else
		ragdollStates[Humanoid] = Ragdolled
	end

	local RagdollScript = Humanoid.Parent:FindFirstChild("Ragdoll")

	if RagdollScript then
		RagdollScript.Ragdolled.Value = Ragdolled
	end
end

I’ve tried different state types, different network owners, I have no idea what’s wrong as it was working before the update

Try making a copy of the character in case if it’s a player, and then attach camera to the new character which is a ragdoll.

I would but I want to be able to modify the players real character, and If I have 2 separate characters then it would be much harder to do that. Thanks for the suggestion, I’ll try it if nobody else gives a working suggestion

Well, in that case you could try detaching player from the character, and then applying the ragdoll.
Like this:

 Player.Charcater = nil
 RagdollFunction(Humanoid,...)
 EndRagdollFunction(Humanoid,...)
 Player.Character = oldCharacter 

From what I know character isn’t read only, so you could try it…
–Solution number 2
You could also lower the humanoid hipheight property as it seems to be an issue.
And also decrease the walkspeed of one.

Huh I didnt know you could do that, Im going to try it

It just deletes the original character. I did fix the issue though, I had to change the state inside of a local script, because a server script didn’t change it for some reason. Thank you for your help!

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