Server-Sided Car will not let player truly die

I am coding an MMX hilldash fangame.
But as you can see, there is a problem.
When my car explodes, it is supposed to kill the player, respawning the menu.
However, It instead deletes the player and does not show the menu.
This is not the case for the bomb.
Footage:
robloxapp-20240614-1541033.wmv (614.3 KB)
Code:

script.Parent.Touched:Connect(function(OP)
	if OP.Name == "RedBomb" then
		local Explosion = Instance.new("Explosion")
		Explosion.Parent = workspace
		Explosion.Position = script.Parent.Position
		Explosion.BlastRadius = 100
		for i, plr in game.Players:GetPlayers() do
			plr.Character:BreakJoints()
		end
		script:Destroy()
	end
end)

before script:Destroy() add the following:

task.delay(2, function()
	plr.Character.Humanoid.Health = 0
end)

This will guarantee that the player dies after 2s of the bomb exploding (you can adress that delay however you want)

same problem.

edit: Nevermind. I fixed it. Just had to edit another script, which was causing the bug. Thanks anyway!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.