Player floats up when ragdolling when still alive

I’d like to fix my ragdolling script, which is intended to be able to use even if the player is not dead. Currently, when ragdolled and alive, the player starts floating up.

https://gyazo.com/cbe9e301998493c92d914c3e6e2b326f

Here’s my code:

local Char = script.Parent
local Hum = Char:WaitForChild("Humanoid")
local Root = Char:WaitForChild("HumanoidRootPart")


local function Ragdoll()
	for i, v in pairs(Char:GetDescendants()) do
		if v:IsA("Motor6D") then
			local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
			a0.CFrame = v.C0
			a1.CFrame = v.C1
			a0.Parent = v.Part0
			a1.Parent = v.Part1
					
			local b = Instance.new("BallSocketConstraint")
			b.Attachment0 = a0
			b.Attachment1 = a1
			b.Parent = v.Parent
					
			v:Destroy()
		end
	end
	Root.CanCollide = false
end

wait(10)

Ragdoll()

If anyone knows what else I need to add or remove, please let me know. Thanks!

2 Likes

Do you happen to have any one of the Legacy Body Movers inside your character’s Torso or HumanoidRootPart before ragdolling? Your script seems fine, so it might be an external force acting on the character.

Have you tried enabling PlatformStand on the Humanoid before ragdolling?

There’s no bodymovers put into my character, and I haven’t - I’ll try that right now.

Alright, so I tried changing the humanoid’s state to platformstanding before it ragdolls, and it still floats.

1 Like

I know this isn’t a solution to why this is happening, but if you Anchor the HumanoidRootPart prior to ragdolling, does it stop floating?

Why don’t you try anchoring the HumanoidRootPart? Not the best way, but it’s the best method I can think of for now.

Well, I did, but it seems to still want to float. And I’m trying to make a bit of a ragdoll engine.

Can I get a video with the HumanoidRootPart anchored? Also, do you have any other scripts in your game that could possibly interfere?

https://gyazo.com/343abda9d3a65bc69c1466a8b1fa0bc4 Also, currently, the ragdoll script is the only script in the game.

Also, the ragdoll works fine on death. https://gyazo.com/c71a691b89907b8a9a89807b5642f7eb

Hmm… Maybe you should try not replacing ALL the Motor6d’s. Normally you wouldn’t want to mess with the one connecting the HumanoidRootPart to the Torso, for instance. Try creating an if statement that checks to make sure that it only replaces the joints that you need to be loose, and see if that helps.

Also make sure that the character’s HumanoidRootPart is not colliding with the other body parts, and causing weird physics.

1 Like

This is from the rootpart colliding with the rest of the body, I don’t know too much of the specifics but if you use some https://developer.roblox.com/en-us/api-reference/class/NoCollisionConstraint on all the parts to the humanoidrootpart, you may be able to get rid of this effect. Simply making the root non cancollide doesn’t fix it due to how humanoids are setup.

Try changing Humanoid State to Ragdoll and disable GettingUp State in client-side.

script.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
script.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp,false)

17 days later… Is it solved yet?

1 Like

I tried out your code here, it helped alleviate the weird floating thing I got from trying to use code from this post: https://devforum.roblox.com/t/ragdoll-on-death-isnt-working/1282308/22, but whenever you walk close to the corpse, the corpse stands up. Not sure what is the root cause of this, also code bellow:

--in server script detecting death
for _, v in pairs(character:GetDescendants()) do
				if v:IsA("Motor6D") then
					local Att0, Att1 = Instance.new("Attachment"), Instance.new("Attachment")
					Att0.CFrame = v.C0
					Att1.CFrame = v.C1
					Att0.Parent = v.Part0
					Att1.Parent = v.Part1
					local BSC = Instance.new("BallSocketConstraint")
					BSC.Attachment0 = Att0
					BSC.Attachment1 = Att1
					BSC.Parent = v.Part0

					v:Destroy()
				end
			end
			character.HumanoidRootPart.CanCollide = false
		
			
			local BodyClone = Instance.new("Model", game.Workspace)
			BodyClone.Name=""
			--local CloneHumanoid = Instance.new("Humanoid", BodyClone)
			--CloneHumanoid.DisplayDistanceType=Enum.HumanoidDisplayDistanceType.None
			
			character:FindFirstChild("Humanoid"):Clone().Parent=BodyClone
			BodyClone.Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
			BodyClone.Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp,false)
			for _, v in pairs (character:GetChildren()) do
				if v:IsA("Humanoid") then continue end
				--if v:IsA("ShirtGraphic") then TShirtId = v.Graphic end
				v.Parent=BodyClone
				
			end
			
--not rly needed as I could do it within the for loop but it helped
--alleviate ragdoll issues such as them spasing out due to collision.
--I should also destroy every local script within.
			coroutine.wrap(function()
				player.CharacterAdded:Wait()
				BodyClone.Health:Destroy()
				BodyClone.Humanoid.Health=0
				BodyClone.HumanoidRootPart.CanCollide=false
				BodyClone.LowerTorso.CanCollide=false
				BodyClone.RightUpperLeg.CanCollide=false
				BodyClone.LeftUpperLeg.CanCollide=false

					--if TShirtId~="" then
						--BodyClone["Shirt Graphic"].Graphic=TShirtId
					--end
			end)()

Ive had the same issue and I came up with the solution of firing a remote event once a player ragdolls on the client side.

Once a player ragdolls if its server sided that its, then just fire a client event that’ll have both

Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)

and to unragdoll, you can just do

Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)

yea firing a remote didn’t change anything from my error

Okay so for anyone reading, I found a different way, what I did was use this: EDIT: IT STILL FREAKING GLITCHES IM JUST GOING TO USE THE BASIC CODE WITHOUT A PERSISTENT MODEL…

I followed instructions except I put the module under the death checker in server script service.

and then I just do:

require(script.Ragdoll):Activate(BodyClone)

and then I wait till the character loads (look at my above code in above post) and then wait 1 second (this is to allow any natural physics to occur i.e. falling from an area, could make it longer) and then anchor all the body parts of the ragdoll (without doing this, the body will start twitching)

for i, v in pairs(BodyClone:GetChildren()) do
					if v:IsA("MeshPart") then
						v.Anchored=true
					end
				end

note after some point you’ll need to fetch all the names of the corpses and destroy them or use the despawn feature depending on your needs.

Since you walk close to it and you move all characters parts into another model, this is probably because of Network Ownership. Try setting all Part network owner to server on server-side using:

Part:SetNetworkOwner(nil)

If that doesn’t solve, can you record from another player’s perspective?

Anything else? I’ve had this on my script for a while and it doesn’t fix the issue

I know this is an old topic but I haven’t found a solution yet in other topics