Why does the ragdoll humanoid state not work?

For my ragdoll, the ragdoll humanoid state type won’t work, I set it to ragdoll and then 3 seconds later, despite it saying the state is “Ragdoll” it just clips through the ground again:

https://gyazo.com/f314e485ebc8d3be55b6b69b3d3bd5f5

local RunService = game:GetService("RunService")

game.ReplicatedStorage.Ragdoll.OnServerEvent:Connect(function(plr, Destroy)
local c = plr.Character
	if Destroy == true then
		_G[plr.Name] = true
		c.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
		c.Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
		c.Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
			for _, v in pairs(c: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
						a0.Name = "DeleteMe"
						a1.Name = "DeleteMe"
						
						v.Part1.CanCollide = true
						v.Part0.CanCollide = true
									
						local b 
						if string.find(v.Part1.Name, "Upper") then
							b = Instance.new("BallSocketConstraint")
							b.LimitsEnabled = true
							b.TwistLimitsEnabled = true
							b.MaxFrictionTorque = 80
							b.TwistLowerAngle = 15
						else
							b = Instance.new("HingeConstraint")
							if string.find(v.Part1.Name, "Leg") or string.find(v.Part1.Name, "Foot") then
							b.LimitsEnabled = true
							b.LowerAngle = -110
							b.UpperAngle = 0
							else
							b.LimitsEnabled = true
							b.LowerAngle = 0
							b.UpperAngle = 110
							end
						end
							
						b.Attachment0 = a0
						b.Attachment1 = a1
						b.Name = "DeleteMe"
						b.Parent = v.Parent	
					
					v:Destroy()
				end
			end
			
			local val = Instance.new("BoolValue", c)
			val.Name = "Grabbable"
			
			local Outline = c.UpperTorso:Clone()
			Outline.Name = "Outline"
			Outline.Parent = c
			Outline.Size = Outline.Size * 1.05
			Outline.Material = Enum.Material.ForceField
			Outline.BrickColor = BrickColor.new("Really black")
			Outline.Transparency = 1
			
			local Weld = Instance.new("WeldConstraint", c)
			Weld.Name = "DeleteMe"
			Weld.Part0 = c.UpperTorso
			Weld.Part1 = Outline
			
			c.PrimaryPart = c.UpperTorso
			c.HumanoidRootPart:FindFirstChild("DeleteMe"):Destroy()
			c.Humanoid.WalkSpeed = 0
			c.Parent = game.Workspace.Items
			
			game.ReplicatedStorage.Ragdoll:FireClient(plr, true)
		else
			c.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, true)
			
			for i ,v in pairs(c:GetDescendants()) do
				if v.Name == "DeleteMe" or v.Name == "Outline" then
					v:Destroy()
				end
			end
				
			c.HumanoidRootPart.Position = c.UpperTorso.Position
			c.Humanoid:BuildRigFromAttachments()
			c:FindFirstChild("Grabbable"):Destroy()
			c.Humanoid.WalkSpeed = 16
			c.Parent = game.Workspace.TargetFilter
			_G[plr.Name] = nil
			game.ReplicatedStorage.Ragdoll:FireClient(plr, false)
	end
end)

The console is always printing Enum.HumanoidStateType.Ragdoll so i don’t get what’s wrong and why it won’t go back to being in ragdoll mode.

2 Likes

What is in the script that changes the Humanoid state next?
Is the HumanoidRootPart still attached to the Humanoid?

I thought I saw this exact same post the other day but it seems to have disappeared.

1 Like

I dont understand what you mean by your first question sorry, But if youre asking if the state is being changed afterwards, its only being changed again when the player gets out of ragdoll mode and no other humanoid state types are printed in the console other than “ragdoll”

The humanoid is not attached to the rest of the character, The Motor6D is deleted and so is the constraint in the humanoidrootpart

and my other post was on the can-collide property of limbs which this humanoidstatetype deals with

1 Like

also i’m pretty sure that state “Ragdoll” doesnt work u need to script the ragdoll

1 Like

Thats what i have done, im only using this state to make the collision for the limbs on

1 Like

Hmm the thing is there isnt much on the humanoidState ragdoll well to my knowledge

1 Like

It is, but it doesn’t do anything. He need to script the arms, legs and more to don’t cancollide. He din’t gave us the entire script so we can’t find the problem.

1 Like

Edit: Withdrawn script
(30 chars)

1 Like

Also just “Scripting the limbs to can-collide” won’t work either, That was the first thing i’ve tried, Then i tried binding it to stepped via a localplayer script, That didn’t work either, Reason i didn’t want to share my full script is people taking it.

1 Like

If you don’t want to show the script, why did you made this topic? We can’t help without the script being public.

Edit: Did you used PhysicsService? If not, check this: PhysicsService | Documentation - Roblox Creator Hub

1 Like

You can’t just set the CanCollide property of characters with humanoids.

To get around this, you have to use Collision Groups.

1 Like

@TheTurtleMaster_2 @ThatTimothy

local PhysicsService = game:GetService("PhysicsService")

PhysicsService:CreateCollisionGroup("Player")
PhysicsService:CollisionGroupSetCollidable("Player", "Map", true)

game.Players.PlayerAdded:Connect(function(plr)
	repeat wait() until plr.Character
	
	for i, v in pairs(plr.Character:GetChildren()) do
		if v:IsA("BasePart") then
			PhysicsService:SetPartCollisionGroup(v)
		end
	end
	
	plr.Character.Humanoid.Died:Connect(function()
		if not _G[plr.Name] then
			game.ReplicatedStorage.Effect:FireClient(plr)
			wait(3)
			plr:LoadCharacter()
		end
	end)
		
	plr.Character.Parent = workspace.TargetFilter
	plr.Character.Humanoid.BreakJointsOnDeath = false
	plr.CharacterAdded:Connect(function(char)
				
		for i, v in pairs(char:GetChildren()) do
			if v:IsA("BasePart") then
				PhysicsService:SetPartCollisionGroup(v)
			end
		end

Something like this should work? Because it’s still doing the same thing

1 Like

Try this:

local PhysicsService = game:GetService("PhysicsService")

PhysicsService:CreateCollisionGroup("Player")
PhysicsService:CollisionGroupSetCollidable("Player", "Map", true)
PhysicsService:CollisionGroupSetCollidable("Player", "Player", false)

game.Players.PlayerAdded:Connect(function(plr)
	repeat wait() until plr.Character
	
	for i, v in pairs(plr.Character:GetChildren()) do
		if v:IsA("BasePart") then
			PhysicsService:SetPartCollisionGroup(v,"Map")
		end
	end
	
	plr.Character.Humanoid.Died:Connect(function()
		if not _G[plr.Name] then
			game.ReplicatedStorage.Effect:FireClient(plr)
			wait(3)
			plr:LoadCharacter()
		end
	end)
		
	plr.Character.Parent = workspace.TargetFilter
	plr.Character.Humanoid.BreakJointsOnDeath = false
	plr.CharacterAdded:Connect(function(char)
				
		for i, v in pairs(char:GetChildren()) do
			if v:IsA("BasePart") then
				PhysicsService:SetPartCollisionGroup(v,"Players")
			end
		end

This is happening because you are not setting the parts to not can collide.

1 Like

The player is still not colliding with the map, The parts are by default un-cancollide and in the window, it shows that both groups are meant to collide:


https://gyazo.com/87151abd2338c6b3569a9a382849b2b1

The player is succesfully bound to the “player” collision group too

1 Like

cc @TheTurtleMaster_2
Make sure you use this line of code: (Player not Players)

PhysicsService:SetPartCollisionGroup(v,"Player")

Collision groups are case-sensitive and have to be the exact same word.

1 Like

I’ve corrected that too and it’s still doing the same thing

local PhysicsService = game:GetService("PhysicsService")

PhysicsService:CreateCollisionGroup("Player")
PhysicsService:CollisionGroupSetCollidable("Player", "Map", true)

game.Players.PlayerAdded:Connect(function(plr)
	repeat wait() until plr.Character
	
	for i, v in pairs(plr.Character:GetChildren()) do
		if v:IsA("BasePart") then
			PhysicsService:SetPartCollisionGroup(v,"Player")
		end
	end
	
	plr.Character.Humanoid.Died:Connect(function()
		if not _G[plr.Name] then
			game.ReplicatedStorage.Effect:FireClient(plr)
			wait(3)
			plr:LoadCharacter()
		end
	end)
		
	plr.Character.Parent = workspace.TargetFilter
	plr.Character.Humanoid.BreakJointsOnDeath = false
	plr.CharacterAdded:Connect(function(char)
				
		for i, v in pairs(char:GetChildren()) do
			if v:IsA("BasePart") then
				PhysicsService:SetPartCollisionGroup(v,"Player")
			end
		end
				
		game.ReplicatedStorage.Ambience:FireClient(plr, "Lobby")
		char:WaitForChild("ForceField"):Destroy()
				
		for i = 0, 50, 1 do
			char.Parent = game.Workspace.TargetFilter
		end
		char.Humanoid.BreakJointsOnDeath = false
		char.Humanoid.Died:Connect(function()
			if not _G[plr.Name] then
				game.ReplicatedStorage.Effect:FireClient(plr)
				wait(3)
				plr:LoadCharacter()
			end
		end)
	end)
end)

This is the full script that i’m using for this

Edit: Nevermind, doesn’t make sense to use physicservice because the limbs are still can-collide off.

2 Likes