Glitchy ragdoll script, HRP floating (NOT FIXED)

Here’s my ragdoll script:

local Players = game:GetService(“Players”)

local hitbox = script.Parent

local TOUCHED = hitbox.Touched

local function RagdollPlayer(hit)
local character = hit.Parent
local player = Players:GetPlayerFromCharacter(character)

if character:FindFirstChild("Humanoid") then
	local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
	local thrower = hitbox:GetAttribute("Thrower")
	
	humanoidRootPart.Anchored = false
	if thrower ~= character.Name then
		for _, limb in pairs(character:GetChildren()) do
			if limb:IsA("BasePart") then
				if limb.Name ~= "Head" and not string.match(limb.Name, "Foot") and not string.match(limb.Name, "Hand") then
					for _, constraint in pairs(limb:GetChildren()) do
						if constraint:IsA("Motor6D") then

							local attachment0 = Instance.new("Attachment")
							attachment0.CFrame = constraint.C0
							attachment0.Parent = constraint.Part0 

							local attachment1 = Instance.new("Attachment")
							attachment1.CFrame = constraint.C1
							attachment1.Parent = constraint.Part1 

							local ballSocketConstraint = Instance.new("BallSocketConstraint")
							ballSocketConstraint.Attachment0 = attachment0
							ballSocketConstraint.Attachment1 = attachment1
							ballSocketConstraint.LimitsEnabled = true
							ballSocketConstraint.TwistLimitsEnabled = true
							ballSocketConstraint.Parent = limb

							constraint:Destroy()
						end
					end
				else
					local weldConstraint = Instance.new("WeldConstraint")
					weldConstraint.Part0 = character:FindFirstChild("Head")
					weldConstraint.Part1 = character:FindFirstChild("UpperTorso")
					weldConstraint.Parent = character:FindFirstChild("Head")
				end
			end
		end
	end
end

end

TOUCHED:Connect(RagdollPlayer)

However it’s a bit glitchy and the player seems to be “floating”, any ideas on why this is happening and how it can be fixed?

Video:

1 Like

This can be fixed by setting the humanoid state to ragdoll and disabling getup state However this is what i use for players i don’t know if this would work on Dummies i never tried it also player humanoid states can only be changed in a local script

Edit: i looked it up and you can change dummies Humanoid State Since they don’t have a Network ownership this can only be used in server scripts

1 Like

local Players = game:GetService(“Players”)
local RunService = game:GetService(“RunService”)

local hitbox = script.Parent

local TOUCHED = hitbox.Touched

local function RagdollPlayer(hit)
local character = hit.Parent
local player = Players:GetPlayerFromCharacter(character)

if character:FindFirstChild("Humanoid") then
	local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
	local humanoid = character:FindFirstChild("Humanoid")
	local thrower = hitbox:GetAttribute("Thrower")

	humanoidRootPart.Anchored = false
	if thrower ~= character.Name then
		for _, limb in pairs(character:GetChildren()) do
			if limb:IsA("BasePart") then
				if limb.Name ~= "Head" and not string.match(limb.Name, "Foot") and not string.match(limb.Name, "Hand") then
					for _, constraint in pairs(limb:GetChildren()) do
						if constraint:IsA("Motor6D") then

							local attachment0 = Instance.new("Attachment")
							attachment0.CFrame = constraint.C0
							attachment0.Parent = constraint.Part0 

							local attachment1 = Instance.new("Attachment")
							attachment1.CFrame = constraint.C1
							attachment1.Parent = constraint.Part1 

							local ballSocketConstraint = Instance.new("BallSocketConstraint")
							ballSocketConstraint.Attachment0 = attachment0
							ballSocketConstraint.Attachment1 = attachment1
							ballSocketConstraint.LimitsEnabled = true
							ballSocketConstraint.TwistLimitsEnabled = true
							ballSocketConstraint.Parent = limb

							local function ChangeHumanoidState()
								
									humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, true)
									humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
								
							end
							
							ChangeHumanoidState()

							constraint:Destroy()
						end
					end
				else
					local weldConstraint = Instance.new("WeldConstraint")
					weldConstraint.Part0 = character:FindFirstChild("Head")
					weldConstraint.Part1 = character:FindFirstChild("UpperTorso")
					weldConstraint.Parent = character:FindFirstChild("Head")
				end
			end
		end
	end
end

end

TOUCHED:Connect(RagdollPlayer)

It kinda works for a little bit, but then after a few seconds it goes back to the floating thing.

Video:

Where is your wait()?
It def looks like something is changed after a while…

What do you mean? What wait() are you talking about?

I mean: What calls this function?

Oh…, I didn’t see the last line

So, uhh do you have any solutions?

This doesn’t change State to RagDoll. It enables RagDoll to be set.

I’m not familiar with RagDoll, but this has a similar effect:

– Turn into loose body:
humanoid:ChangeState(Enum.HumanoidStateType.Physics)

I doesn’t have to be in function

1 Like

The humanoid root part still floats.

Still not fixed, if anyone knows anything that might help, pls lmk.

Disable getup state and set it back to true when you want him to get up

Oh also i found an issue in the code your setting ragdoll state to true its true by default you need to Changestate() to ragdoll not set state enabled

You are going to have to put a bunch of Prints, all over to find out what is going on.

Or use the Ragdoll script from Roblox, and modify it:

NPC Kit (roblox.com)

From the Wiki, this seems to say, that, Ragdoll may be turned-off, but if getting up is Disabled, who knows what State will be turned on…? It sure looks like it is trying to get-up…

If you set the State to Physics at some point I’m pretty sure it WILL stay in THAT state.

The Humanoid will enter the GettingUp state 1 second after the Ragdoll state is enabled. When this happens this event will fire with an active value of false , and Humanoid.GettingUp will fire with an active value of true .

There is also a script here which Prints-out it’s state:

Humanoid.Ragdoll (roblox.com)

You can try setingt it’s Humanoid’s Parent to nil; then re-Parent it to the Model… (I know in a Local Script you can de-parent a Server Model, then re-parent it) Try everything…

GL

Try humanoid.PlatformStand = true

1 Like