So in the script the function runRounds() works with 'round1' as the parameter. Everything goes well, and when one of the players dies, it will run the function again, but on the line where it teleports the players back to the spawn, the player who died does not tp back into the spawn.
local Players = game:GetService('Players')
local replicatedStorage = game:GetService('ReplicatedStorage')
local arena = script.Parent
local spawns = arena.spawns
local pad = arena.pad
local pad1 = arena.pad1
local board = arena.board
local boardgui = board.SurfaceGui
local status = arena.status
local timeLeft = arena:WaitForChild('timeLeft')
local round = arena.round
local sword = replicatedStorage.Sword
local function runRounds(round)
print("started "..status.Value)
local user = tostring(pad.player.Value)
local user1 = tostring(pad1.player.Value)
local player = game.Workspace[user]
local player1 = game.Workspace[user1]
local winner
player.Humanoid.Died:Connect(function()
winner = player1.Name
print(player1.Name.." won ".. status.Value.."!")
if round == "round1" then
status.Value = "round2"
runRounds(tostring(status.Value))
elseif round == "round2" then
status.Value = "round3"
runRounds(tostring(status.Value))
elseif round == "round3" then
status.Value = "intermission"
round.Value = "waiting"
db = false
end
end)
player1.Humanoid.Died:Connect(function()
winner = player.Name
print(player.Name.." won ".. status.Value.."!")
if round == "round1" then
status.Value = "round2"
runRounds(tostring(status.Value))
elseif round == "round2" then
status.Value = "round3"
runRounds(tostring(status.Value))
elseif round == "round3" then
status.Value = "intermission"
round.Value = "waiting"
db = false
end
end)
--this part of the script is what doesntwork for when the player who just dies vvv
player:WaitForChild('HumanoidRootPart').CFrame = spawns.spawn.CFrame
player1:WaitForChild('HumanoidRootPart').CFrame = spawns.spawn1.CFrame
--rest of the script
print("spawned")
if status.Value == 'round1' then
local sword1 = sword:Clone()
local sword2 = sword:Clone()
sword1.Parent = player
sword2.Parent = player1
elseif status.Value ~= 'round1' then
if winner == player1.Name then
local sword1 = sword:Clone()
sword1.Parent = player
else
local sword1 = sword:Clone()
sword1.Parent = player1
end
end
end
