Something that tells me if a character spawned after death? I tried this but it doesnt seem to be working?
game.Players.PlayerAdded:connect(function(ply) ply.CharacterAdded:connect(function(char) print("works") --It doesnt print at all end) end)
The first thing you should do is getting the player's name. Here is a simple way to:
local PlayerName = "?" game.Players.PlayerAdded:Connect(function(player) PlayerName = player.Name end)
...and then, you need to store the character's health...
-- Change the previous script to this: local PlayerName = "?" local PlayerHumanoid = "?" game.Players.PlayerAdded:Connect(function(player) PlayerName = player.Name PlayerHumanoid = player:FindFirstChild("Humanoid") end) PlayerHumanoid = PlayerHumanoid.Health
..now, you will want to detect whenever the player dies? right?
-- Change the previous script to this: local PlayerName = "?" local PlayerHumanoid = "?" game.Players.PlayerAdded:Connect(function(player) PlayerName = player.Name PlayerHumanoid = player:FindFirstChild("Humanoid") end) PlayerHumanoid = PlayerHumanoid.Health if PlayerHumanoid == 0 then print("Player Died!") end
..lastly, lets go to the point of what you ask!
-- Change the previous script to this: local PlayerName = "?" local PlayerHumanoid = "?" game.Players.PlayerAdded:Connect(function(player) PlayerName = player.Name PlayerHumanoid = player:FindFirstChild("Humanoid") end) PlayerHumanoid = PlayerHumanoid.Health if PlayerHumanoid == 0 then print("Player Died!") wait(5) -- This is the normal delay between every character's death game.Workspace:WaitForChild(PlayerName, 1) print("Player has respawned!") end
Hope this helps! Tell me if it's wrong... :P