Player Not Dying Instantly

HEY DEVELOPERS!

My game has a system where players become ghosts on death. At the start of a round, everyone dies to reset to regular characters and teleport into the game. The problem is, sometimes ghosts don’t die instantly. They respawn after two seconds, despite their health being zero.

DOES ANYONE KNOW WHY THIS IS HAPPENING?

did you set the respawn time to 0? also, hence this is in #help-and-feedback:scripting-support, we’ll need to see at least part of your script.

The respawn time is 0, and here is the code.

	for _, player in ipairs(Players:GetPlayers()) do
		if player:WaitForChild("AFK").Value == false then
			local character = player.Character or player.CharacterAdded:Wait()
			local humanoid = character:WaitForChild("Humanoid")
			humanoid.Health = 0
		end
	end
	
	task.wait(1.5)

	ReplicatedStorage.Values.Game.Value = true

	task.wait(1)

	ReplicatedStorage.TransitionEvent:FireAllClients(false)

	for _, player in ipairs(Players:GetPlayers()) do
		if player:WaitForChild("AFK").Value == false then
			local character = player.Character or player.CharacterAdded:Wait()
			table.insert(playersInGame, player)

			local value = Instance.new("ObjectValue")
			value.Name = player.Name
			value.Value = player
			value.Parent = ReplicatedStorage.Values.PlayersInGame

			player:WaitForChild("Matches", math.huge).Value += 1

			character:WaitForChild("HumanoidRootPart", math.huge).CFrame = map.Spawns:GetChildren()[math.random(1, #map.Spawns:GetChildren())].CFrame
		end
	end
1 Like

Try Player:LoadCharacter(), it instantly creates a new character for the player and removes the old one instead of killing the player.

2 Likes

Thank you so much, it works perfect!

1 Like

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