this script is supposed to be a function to teleport 2 players after one of them has died. It appears that the script isnt detecting that the player is dead. Any help?
function EndGame()
local players = game.Players:GetPlayers()
local teleportPart = "RespawnPoint"
local char1 = game.Teams.Fighting1:GetPlayers()
local char2 = game.Teams.Fighting2:GetPlayers()
local hum1 = char1.character:WaitForChild("Humanoid")
local hum2 = char2.character:WaitForChild("Humanoid")
print ("the function has worked!")
while hum1.Died
do print(char1.Name.." has died.")
print(char2.Name.." has won.")
wait(4)
char1.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(267, 22.565, 216.5))
char2.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(267, 22.565, 216.5))
end
while hum2.Died
do print(char2.Name.." has died.")
print(char1.Name.." has won.")
wait(4)
char1.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(267, 22.565, 216.5))
char2.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(267, 22.565, 216.5))
end
end
