Hello! Im making it so that after every round of fighting, both the players are teleported.
However, this isn’t working and only the player who killed the other player gets teleported.
The player who dies doesn’t get teleported at all.
There are no errors in the output, and even prints "teleported player 2"
even though it doesn’t. If anybody could help me, I would really appreciate it.
Thank you.
function respawnPlayers()
local Character1 = game.Players:FindFirstChild(Player1.Value).Character
print('got character 1')
local Character2 = game.Players:FindFirstChild(Player2.Value).Character
print('got character 2')
local HumanoidRootPart1 = Character1:FindFirstChild("HumanoidRootPart") or Character1:WaitForChild("HumanoidRootPart")
print('got hrp1')
local HumanoidRootPart2 = Character2:FindFirstChild("HumanoidRootPart") or Character2:WaitForChild("HumanoidRootPart")
print('got hrp2')
HumanoidRootPart1.CFrame = Spawnpoints.Player1.CFrame
print('tpd player1')
HumanoidRootPart2.CFrame = Spawnpoints.Player2.CFrame
print('tpd player2')
roundnum = roundnum + 1
round(roundnum)
end
function round(num)
if num == 0 then
game.ReplicatedStorage.CountdownFight:FireClient(game.Players:FindFirstChild(Player1.Value))
game.ReplicatedStorage.CountdownFight:FireClient(game.Players:FindFirstChild(Player2.Value))
game.Players:FindFirstChild(Player1.Value).Character.Humanoid.Died:Connect(function()
player1death = player1death + 1
print('player 1 death and player 2 won')
respawnPlayers()
end)
game.Players:FindFirstChild(Player2.Value).Character.Humanoid.Died:Connect(function()
player2death = player2death + 1
print('player 2 death and player 1 won')
respawnPlayers()
end)