Car Falling through the map when my player Dies

The issue is my car will fall through the map when a player is in it and dies in it.
i have tried to make the character cancolide but that will make the player fall through the map

This is the script for the ragdoll script when u die

--Put this inside the NPC you want to ragdoll on death
--Made by Yabsor


-- Function to turn off collision for parts
local function cancolideoff(humanoid)
	for _, v in pairs(humanoid.Parent:GetChildren()) do
		if v:IsA("BasePart") then
			v.CanCollide = true
		end
	end
end














local Humanoid = script.Parent:FindFirstChild("Humanoid")
local Head = script.Parent:FindFirstChild("Head")
local RightArm = script.Parent:FindFirstChild("Right Arm")
local RightLeg = script.Parent:FindFirstChild("Right Leg")
local LeftArm = script.Parent:FindFirstChild("Left Arm")
local LeftLeg = script.Parent:FindFirstChild("Left Leg")
local Torso = script.Parent:FindFirstChild("Torso")
Humanoid.BreakJointsOnDeath = false

local NewTorsoToHead1 = Instance.new("Attachment") --Head 1
NewTorsoToHead1.Position = Vector3.new(0, -0.6, 0)
NewTorsoToHead1.Name = "TorsoToHead1"
NewTorsoToHead1.Parent = Head

local NewTorsoToRightArm1 = Instance.new("Attachment") --Right arm 1
NewTorsoToRightArm1.Position = Vector3.new(-0.5, 0.5, 0)
NewTorsoToRightArm1.Name = "TorsoToRightArm1"
NewTorsoToRightArm1.Parent = RightArm

local NewTorsoToRightLeg1 = Instance.new("Attachment") --Right leg 1
NewTorsoToRightLeg1.Position = Vector3.new(0, 1, 0)
NewTorsoToRightLeg1.Name = "TorsoToRightLeg1"
NewTorsoToRightLeg1.Parent = RightLeg

local NewTorsoToLeftArm1 = Instance.new("Attachment") --Left arm 1
NewTorsoToLeftArm1.Position = Vector3.new(0.5, 0.5, 0)
NewTorsoToLeftArm1.Name = "TorsoToLeftArm1"
NewTorsoToLeftArm1.Parent = LeftArm

local NewTorsoToLeftLeg1 = Instance.new("Attachment") --Left leg 1
NewTorsoToLeftLeg1.Position = Vector3.new(0, 1, 0)
NewTorsoToLeftLeg1.Name = "TorsoToLeftLeg1"
NewTorsoToLeftLeg1.Parent = LeftLeg

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

local NewTorsoToHead0 = Instance.new("Attachment") --Head 0
NewTorsoToHead0.Position = Vector3.new(0, 1, 0)
NewTorsoToHead0.Name = "TorsoToHead0"
NewTorsoToHead0.Parent = Torso

local NewTorsoToRightArm0 = Instance.new("Attachment") --Right arm 0
NewTorsoToRightArm0.Position = Vector3.new(1, 0.5, 0)
NewTorsoToRightArm0.Name = "TorsoToRightArm0"
NewTorsoToRightArm0.Parent = Torso

local NewTorsoToRightLeg0 = Instance.new("Attachment") --Right leg 0
NewTorsoToRightLeg0.Position = Vector3.new(0.5, -1, 0)
NewTorsoToRightLeg0.Name = "TorsoToRightArm0"
NewTorsoToRightLeg0.Parent = Torso

local NewTorsoToLeftArm0 = Instance.new("Attachment") --Left arm 0
NewTorsoToLeftArm0.Position = Vector3.new(-1, 0.5, 0)
NewTorsoToLeftArm0.Name = "TorsoToLeftArm0"
NewTorsoToLeftArm0.Parent = Torso

local NewTorsoToLeftLeg0 = Instance.new("Attachment") --Left leg 0
NewTorsoToLeftLeg0.Position = Vector3.new(-0.5, -1, 0)
NewTorsoToLeftLeg0.Name = "TorsoToLeftLeg0"
NewTorsoToLeftLeg0.Parent = Torso

Humanoid.Died:Connect(function() --Death
	cancolideoff(Humanoid)
	
	local function CreateBallSocket(Attachment0, Attachment1, TwistLowerAngle, TwistUpperAngle)
		local BallSocket = Instance.new("BallSocketConstraint")
		BallSocket.Attachment0 = Attachment0
		BallSocket.Attachment1 = Attachment1
		BallSocket.LimitsEnabled = true
		BallSocket.TwistLimitsEnabled = true
		BallSocket.TwistLowerAngle = TwistLowerAngle
		BallSocket.TwistUpperAngle = TwistUpperAngle
		BallSocket.MaxFrictionTorque = 10
		BallSocket.Parent = Torso
	end
	CreateBallSocket(NewTorsoToHead0, NewTorsoToHead1, -45, 45)
	CreateBallSocket(NewTorsoToRightArm0, NewTorsoToRightArm1, 45, 0)
	CreateBallSocket(NewTorsoToLeftArm0, NewTorsoToLeftArm1, 0, 45)
	CreateBallSocket(NewTorsoToRightLeg0, NewTorsoToRightLeg1, -45, 45)
	CreateBallSocket(NewTorsoToLeftLeg0, NewTorsoToLeftLeg1, -45, 45)
	Torso.Parent.HumanoidRootPart:Destroy()

	local LeftHip = Torso:FindFirstChild("Left Hip")
	if LeftHip then
		LeftHip:Destroy()
	end
	local LeftShoulder = Torso:FindFirstChild("Left Shoulder")
	if LeftShoulder then
		LeftShoulder:Destroy()
	end
	local Neck = Torso:FindFirstChild("Neck")
	if Neck then
		Neck:Destroy()
	end
	local RightShoulder = Torso:FindFirstChild("Right Shoulder")
	if RightShoulder then
		RightShoulder:Destroy()
	end
	local RightHip = Torso:FindFirstChild("Right Hip")
	if RightHip then
		RightHip:Destroy()
	end
	
	
	
	local model = script.Parent
	local rotation = CFrame.Angles(math.rad(math.random(-10,-1)), math.rad(math.random(1,30)), math.rad(math.random(-20,-1)))
	local modelCFrame = model:GetPivot()
	model:PivotTo(modelCFrame * rotation)
	
	
	local headX = script.Parent.Head.Position.X
	local headY = script.Parent.Head.Position.Y
	local headZ = script.Parent.Head.Position.Z
	
	
	local explosion = Instance.new("Explosion")
	explosion.Position = script.Parent["Right Leg"].Position
	explosion.BlastRadius = 1
	explosion.Parent = script.Parent:FindFirstChild("Right Leg")
	explosion.Visible = false
	
end)


-- Add a check for falling or other conditions where you want to disable collisions
Humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
	-- Example: Check if humanoid is falling (assuming this can be determined by FloorMaterial)
	if Humanoid.FloorMaterial == Enum.Material.Air then
		-- Disable collisions if falling (you may need to adjust this logic based on your game's specifics)
		cancolideoff(Humanoid)
	end
end)

maybe is there some kind of bool value i can change on the car for it not to glitch like this

1 Like

diagoinsis: skill issue

Perhaps try making the humanoid stand up before doing the ragdoll to ensure it’s not welded to any seats?

The explosion, even though it has a blast radius of 1 stud, may be doing something funky with the constraints of the vehicle. Try setting DestroyJointRadiusPercent for the explosion to 0 before parenting it to the workspace.

1 Like

this my first time posting on the dev fourm. and this is alr so helpful. Tysm i had no idea about that destroyjointradius percent