Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is my toggleable R6 ragdoll script not working correctly, and how do I fix it?

So i was making this toggleable R6 ragdoll script and then i stubbled across this problem where the limbs were clipping through the baseplate and pretty much didn't collide with anything, is there a way to fix this?

Script -

local Character = script.Parent
local Ragdoll = Character:WaitForChild("Ragdoll")

script.Parent.Humanoid.BreakJointsOnDeath = false

Ragdoll.Changed:Connect(function(newValue)
	
if newValue == true then

		script.Parent.Humanoid.PlatformStand = true
		script.Parent.Humanoid.AutoRotate = false
	
		for i, v in pairs(script.Parent.Torso:GetChildren()) do
			if v:IsA("Motor6D") then
			v.Part0 = nil
			end
		end
		
		local HA1 = Instance.new("Attachment",script.Parent.Head)
		local HA2 = Instance.new("Attachment",script.Parent.Torso)
		local RAA1 = Instance.new("Attachment",script.Parent["Right Arm"])
		local RAA2 = Instance.new("Attachment",script.Parent.Torso)
		local LAA1 = Instance.new("Attachment",script.Parent["Left Arm"])
		local LAA2 = Instance.new("Attachment",script.Parent.Torso)
		local RLA1 = Instance.new("Attachment",script.Parent["Right Leg"])
		local RLA2 = Instance.new("Attachment",script.Parent.Torso)
		local LLA1 = Instance.new("Attachment",script.Parent["Left Leg"])
		local LLA2 = Instance.new("Attachment",script.Parent.Torso)
		
		local HC = Instance.new("BallSocketConstraint",script.Parent.Torso)
		local RAC = Instance.new("BallSocketConstraint",script.Parent.Torso)
		local LAC = Instance.new("BallSocketConstraint",script.Parent.Torso)
		local RLC = Instance.new("BallSocketConstraint",script.Parent.Torso)
		local LLC = Instance.new("BallSocketConstraint",script.Parent.Torso)
		
		HA1.Position = Vector3.new(0,-0.5,0)
		RAA1.Position = Vector3.new(-0.5,1,0)
		LAA1.Position = Vector3.new(0.5,1,0)
		RLA1.Position = Vector3.new(0,1,0)
		LLA1.Position = Vector3.new(0,1,0)
		
		HA2.Position = Vector3.new(0,1,0)
		RAA2.Position = Vector3.new(1,1,0)
		LAA2.Position = Vector3.new(-1,1,0)
		RLA2.Position = Vector3.new(0.5,-1,0)
		LLA2.Position = Vector3.new(-0.5,-1,0)
		
		HC.Attachment0 = HA2
		HC.Attachment1 = HA1
	
		RAC.Attachment0 = RAA2
		RAC.Attachment1 = RAA1
		
		LAC.Attachment0 = LAA2
		LAC.Attachment1 = LAA1
	
		RLC.Attachment0 = RLA2
		RLC.Attachment1 = RLA1
	
		LLC.Attachment0 = LLA2
		LLC.Attachment1 = LLA1
		
	elseif newValue == false then
		
		script.Parent.Humanoid.PlatformStand = false
		script.Parent.Humanoid.AutoRotate = true
		
		for i, v in pairs(script.Parent.Torso:GetChildren()) do
			if v:IsA("Attachment") then
				if v.Name == "Attachment" then
					
					v:Destroy()
					
				end
				
			elseif v:IsA("BallSocketConstraint") then
				
				v:Destroy()
				
			end
		end
		
		for i, v in pairs(script.Parent.Torso:GetChildren()) do
			if v:IsA("Motor6D") then
				v.Part0 = Character.Torso
			end
		end
	end
end)

1 answer

Well normally the player's bodyparts's CanCollide property is set to false when they enter a game, but whenever they die the CanCollide property is set to true, due to your ragdoll script being toggleable I the CanCollide property for each bodypart is set to true before ragdolling?

So all you have to do is iterate through the player's character and set the bodyparts's CanCollide property to true

for i,BodyPart in pairs(Player.Character:GetChildren()) do
	if BodyPart:IsA("BasePart") then
		BodyPart.CanCollide = true
	end
end

Anyways hopefully this might help a bit, but I am not sure if you ment that the whole character only clipped through the baseplate or just some parts due to HumanoidRootPart having its CanCollide property set to true.

1 comment

0

Yes, i did try setting the body part CanCollide to true but the game automatically switces it back to false on the arms, legs and head, is there another method?

This discussion is preserved as it was. New answers, comments, and votes are closed.