I want this to happen each time the player health is 0
local player = game.Players local players = player.LocalPlayer local char = player.Character humanoid = char:FindFirstChild("Humanoid") function loadcharacter(respawn) if humanoid.Health > 1 then player:GetPlayerFromCharacter(respawn):LoadCharacter() end end
Error: Character is not a valid member of Players Help?
On line 3, you're trying to set char to player.Character, but player is set to game.Players. The following should work.
local player = game.Players local players = player.LocalPlayer local char = players.Character humanoid = char:FindFirstChild("Humanoid") function loadcharacter(respawn) if humanoid.Health > 1 then player:GetPlayerFromCharacter(respawn):LoadCharacter() end end
write this in a local script and place it into StarterGui
local player = game.Players.LocalPlayer local char = player.Character local humanoid = char:FindFirstChild("Humanoid") while wait() do if humanoid.Health < 1 then player:GetPlayerFromCharacter:LoadCharacter() end