Hello, I am making a script where it chooses a random map every round, like Intermission ? Round Starting, and see if there is only one player in a table, if so they get money ? round restarting.
The problem is that when I want to teleport the people in the table, the script only teleports one player, not all of them. ( When I mean teleport, I mean teleport to the map, not to another game. )
--Server Script
local RepStorage = game:GetService("ReplicatedStorage")
local rEvent = RepStorage.RemoteEvents:WaitForChild("checkIf_inMainMenuOrLoading")
local IsVisorNot = nil
local InLobby = {}
local contestants = {}
local Status = game:GetService("ReplicatedStorage"):WaitForChild("Status")
local MapsFol = game:GetService("ReplicatedStorage"):WaitForChild("MapsStorage"):GetChildren()
local ClonedMapsFolder = Instance.new("Folder", workspace)
ClonedMapsFolder.Name = "ClonedMapsFolder"
local WinnerStatus = RepStorage:WaitForChild("RoundWinnerName")
local RoundMod = require(script.Parent.ModuleScripts.RoundHandlerModule)
local RoundAmount = RepStorage:WaitForChild("RoundAmount")
local MarketPlaceService = game:GetService("MarketplaceService")
-- Variables
rEvent.OnServerEvent:Connect(function(plr)
table.insert(contestants, plr)
for pos, v in pairs(contestants) do
warn(contestants[pos].Name.. " has joined the Contestants table")
end
end)
while true do
RoundMod.NeedMorePlayers()
repeat wait() until #contestants >= 1
local ranNum = math.random(1, #MapsFol)
local ranAmount = math.random(10, 25)
RoundAmount.Value = ranAmount
RoundMod.RoundIntermission(7)
if ranNum == 1 then
for i, plr in pairs(contestants)do
local char = plr.Character
local humRootPart = char:FindFirstChild("HumanoidRootPart")
RoundMod.ChosenMap("Holy One", Status)
local ClonedMap = RepStorage.MapsStorage:FindFirstChild("ForestMap"):Clone()
local SpawnPoints = nil
if workspace:FindFirstChild("ClonedMapsFolder") then
ClonedMap.Parent = ClonedMapsFolder
SpawnPoints = ClonedMap.HolysOne:FindFirstChild("Spawns")
print("Cloned Maps Folder does Exist!")
else
warn("The Cloned Maps Folder Doesn't exist!")
end
if not SpawnPoints then
warn("No Spawn Points in Holys One were Found!")
end
local AvaliableSpawnPoints = SpawnPoints:GetChildren()
print("The Chosen Map is The Holys One.")
if char and game.Workspace:FindFirstChild(contestants[i].Name) then
humRootPart.CFrame = AvaliableSpawnPoints[1].CFrame
table.remove(AvaliableSpawnPoints, 1)
warn("hi")
else
warn("Why today?")
end
for i = 10, 0, -1 do
if #contestants == 1 then
local hasPass = false
WinnerStatus.Value = contestants[1].Name
local success, fail = pcall(function()
hasPass = MarketPlaceService:UserOwnsGamePassAsync(plr.UserId, 16170736)
end)
if not hasPass and not plr:FindFirstChild("GamePassFolder") then
contestants[1].leaderstats.Scaxxe.Value = contestants[1].leaderstats.Scaxxe.Value + RoundAmount
else
local newAmount = RoundAmount.Value * 2
contestants[1].leaderstats.Scaxxe.Value = contestants[1].leaderstats.Scaxxe.Value + newAmount
end
Status.Value = WinnerStatus.Value.." has Won the Game!"
wait(5)
break
end
Status.Value = "Round in Progress: "..i.." seconds left"
wait(1)
if i == 0 then
break
end
end
RoundMod.CleanUpMaps(ClonedMapsFolder)
end
elseif ranNum == 2 then
for i, plr in pairs(contestants) do
local char = plr.Character
local humRootPart = char:FindFirstChild("HumanoidRootPart")
RoundMod.ChosenMap("Unknown Territory", Status)
local ClonedMap = RepStorage.MapsStorage:FindFirstChild("UnknownTerritory"):Clone()
local SpawnPoints = nil
if workspace:FindFirstChild("ClonedMapsFolder") then
ClonedMap.Parent = ClonedMapsFolder
SpawnPoints = ClonedMap.UnknownTerritory:FindFirstChild("Spawns")
print("Cloned Maps Folder does Exist!")
else
warn("The Cloned Maps Folder Doesn't exist!")
end
if not SpawnPoints then
warn("No Spawn Points in Unknown Territory were Found!")
end
local AvaliableSpawnPoints = SpawnPoints:GetChildren()
print("The Chosen Map is The Unknown Territory.")
if char and workspace:FindFirstChild(contestants[i].Name) then
humRootPart.CFrame = AvaliableSpawnPoints[1].CFrame
table.remove(AvaliableSpawnPoints, 1)
warn("Congrats, I've Done Something Cool in Life...")
else
warn("Why today?")
end
for i = 10, 0, -1 do
if #contestants == 1 then
local hasPass = false
WinnerStatus.Value = contestants[1].Name
local success, fail = pcall(function()
hasPass = MarketPlaceService:UserOwnsGamePassAsync(plr.UserId, 16170736)
end)
if not hasPass and not plr:FindFirstChild("GamePassFolder") then
contestants[1].leaderstats.Scaxxe.Value = contestants[1].leaderstats.Scaxxe.Value + RoundAmount
else
local newAmount = RoundAmount.Value * 2
contestants[1].leaderstats.Scaxxe.Value = contestants[1].leaderstats.Scaxxe.Value + newAmount
end
Status.Value = WinnerStatus.Value.." has Won the Game!"
wait(5)
break
end
Status.Value = "Round in Progress: "..i.." seconds left"
wait(1)
if i == 0 then
break
end
end
wait(5)
RoundMod.CleanUpMaps(ClonedMapsFolder)
end
end
end
game:GetService("Players").PlayerRemoving:Connect(function(plr)
for i, _ in pairs (game:GetService("Players"):GetPlayers()) do
table.remove(InLobby, i) table.remove(contestants, i)
print(plr.Name.." has been removed from the contestants or InLobby table")
end
end)
-- Module Script
local module = {}
module.CleanUpMaps = function(MapsHolder)
MapsHolder:Destroy()
end
module.ChosenMap = function(ChosenMap, Status)
Status.Value = "The Chosen Map is "..ChosenMap.." ! Get Ready To Play!"
end
function module.RoundIntermission(length)
local Status = game:GetService("ReplicatedStorage"):WaitForChild("Status")
for i = length, 0, -1 do
Status.Value = "Intermission: "..i.." seconds left"
wait(1)
if i == 0 then
break
end
end
end
module.NeedMorePlayers = function()
print("Need More Players To Start the Game.")
local Status = game:GetService("ReplicatedStorage"):WaitForChild("Status")
Status.Value = "Need one more player to start the game..."
end
return module
Thanks again!

1 comment
that is a long script