For some reason my round script respawns every player if one dies. So lets say one guy resets, the round system moves every player to the original spawn point or a totally different map. I really need help since I don’t know whats wrong with it. The script is below.
–Server–
wait()
local Map1 = game.ServerStorage.Maps.BoardWalk
local Map2 = game.ServerStorage.Maps.ShipMap
local spawnthing = game.Workspace.SpawnLocation
local function RanMap()
local players = game.Players:GetChildren()
local RanNum = math.random(1,2)
if RanNum == 1 then
script.Timer:FireAllClients()
Map1:Clone().Parent = workspace
for i = 1, #players do
players[i].Character:MoveTo(Vector3.new(-295.952, 23.407, 731.36)) -- Spawn Part Position in map
end
elseif RanNum == 2 then
script.Timer:FireAllClients()
Map2:Clone().Parent = workspace
for i = 1, #players do
players[i].Character:MoveTo(Vector3.new(-712.07, 216.8, -579.04))
spawnthing.Position = Map2.Spawns.SpawnPoint.Position
end
end
end
local function Wipe()
local Map1Find = workspace:FindFirstChild("Map1")
local Map2Find = workspace:FindFirstChild("Map2")
if Map1Find then
Map1Find:Destroy()
elseif Map2Find then
Map2Find:Destroy()
end
end
script.Finished.OnServerEvent:Connect(function(Player)
local players = game.Players:GetChildren()
for i = 1, #players do
players[i].Character:MoveTo(Vector3.new(-787.03, 154.744, -146.242)) -- Lobby SpawnPoint Position
spawnthing.Position = game.Workspace.Reactor.SpawnPos.Position
end
wait(2)
Wipe()
wait()
script.LobbyTimer:FireAllClients()
end)
script.FinishedLobby.OnServerEvent:Connect(function(Player)
RanMap()
end)
RanMap()
–Local–
local Timer = script.Parent.Parent.Timer
local Frame = script.Parent.Parent.Transition
local function LobbyToGame()
Frame.Visible = true
Frame:TweenPosition(UDim2.new(-0, 0,-0, 0),"Out","Sine",1)
wait(1)
Frame:TweenPosition(UDim2.new(-1, 0,0, 0),"Out","Sine",1)
script.Parent.FinishedLobby:FireServer()
wait(2)
Frame.Visible = false
end
script.Parent.Timer.OnClientEvent:Connect(function()
local seconds = 360 -- Each Round Timer (Changable)
local minutes = seconds/60
repeat
seconds = seconds - 1
if seconds < 60 then
Timer.Text = "Game In Progress.. ".. seconds
elseif seconds >= 60 then
Timer.Text = "Game In Progress.. ".. minutes
end
wait(1)
until
seconds <= 0
script.Parent.Finished:FireServer()
end)
script.Parent.LobbyTimer.OnClientEvent:Connect(function()
local seconds = 30 -- Lobby Timer (Changable)
repeat
seconds = seconds - 1
Timer.Text = "Lobby: ".. seconds
wait(1)
until
seconds <= 0
LobbyToGame()
end)