Not eject player from seat on death?

Currently, I’d like to have it where when a player dies while inside of a vehicle, their dead body ragdoll stays in the vehicle which can be ejected by other players. The only issue with this is when a player dies, they’re instantly ejected by default meaning there is no time to get their seat or if they’re sitting.

Is there a way to not automatically unsit players after death? If not, what would be the best way to check if a player was sitting when they died?

2 Likes

Weld the player to the seat when they sit

2 Likes

Thank you for the suggestion but I ended up doing it differently.

I ended up having to find a workaround.

Instead of using the humanoid to see if the player is sitting, the players character has a bool attribute called “Sit”, and an object value for the seat they’re sitting in, and just detecting humanoid sitting and applying values accordingly. Not the best solution but it works :man_shrugging:

1 Like
local run = game:GetService("RunService")
local players = game:GetService("Players")
local debris = game:GetService("Debris")

local lastSeat = {}

players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid")
		local hrp = character:WaitForChild("HumanoidRootPart")
		humanoid.BreakJointsOnDeath = false
		humanoid.Died:Connect(function()
			if lastSeat[player] then
				local weld = Instance.new("Weld")
				weld.Name = "SeatWeld"
				weld.Part0 = lastSeat[player]
				weld.Part1 = hrp
				weld.C0 = hrp.CFrame
				weld.C1 = lastSeat[player].CFrame
				weld.Parent = lastSeat[player]
				debris:AddItem(weld, players.RespawnTime)
			end
		end)
		
		humanoid:GetPropertyChangedSignal("SeatPart"):Connect(function()
			if humanoid:GetState() ~= Enum.HumanoidStateType.None then
				lastSeat[player] = humanoid.SeatPart
			end
		end)
	end)
end)

players.PlayerRemoving:Connect(function(player)
	lastSeat[player] = nil
end)

I’m guessing your solution was something similar to this.

1 Like