I’m using this round system made by @reccur and I modified it.
I added something to pick a random person to be a giant and the objective of the giant is to kill everyone. The system only has 1 spawn part so I decided to add more and I used math.random() to pick a spawn point for the player.
Every time I test it, it says “everyone has died.”
I’m assuming this is because of the random spawn thing.
Code:
-------------------------------------[AUTHOR: reccur]--------------------------------
local intermission = 25
local roundLength = 300
local inRound = game.ReplicatedStorage.InRound
local staus = game.ReplicatedStorage.Status
local playingTeam = game.Teams.Playing
local lobbyTeam = game.Teams.Lobby
inRound.Changed:Connect(function()
if inRound.Value == true then
local players = game.Players:GetChildren()
local random_giant = math.random(0,#players ) ---picks a random person to be the giant.
print("PICKED GIANT")
local giant_name = players[random_giant].Name
print("GIANT_NAME")
game.ReplicatedStorage.Events.size_player:Fire(players[random_giant])
print("FIRED GIANT EVENT")
for i, plr in pairs(game.Players:GetChildren()) do
local spawn_folder = game.Workspace["Map Spawns"]:GetChildren()
local random_spawn = math.random(0, #spawn_folder)
local char = plr.Character
local humanRoot = char:WaitForChild("HumanoidRootPart")
local random_s = game.Workspace["Map Spawns"]:FindFirstChild(spawn_folder[random_spawn].Name)
humanRoot.CFrame = random_s.CFrame
plr.Team = playingTeam
char:WaitForChild("Humanoid").Died:Connect(function()
plr.Team = lobbyTeam
end)
end
else
for i, plr in pairs(game.Players:GetChildren()) do
local char = plr.Character
local humanRoot = char:WaitForChild("HumanoidRootPart")
humanRoot.CFrame = game.Workspace.lobbySpawn.CFrame
plr.Team = lobbyTeam
end
end
end)
local function round()
while true do
local requiredPlayers = 2
repeat
wait(1)
staus.Value = "Atleast ".. requiredPlayers.." players are needed to start a round"
until #game.Players:GetChildren() >= requiredPlayers
inRound.Value = false
for i = intermission, 0, -1 do
staus.Value = "Game will start in "..i.." seconds"
wait(1)
end
inRound.Value = true
for i = roundLength, 0, -1 do
staus.Value = "Game will end in "..i.." seconds"
local playing = {}
for i, plr in pairs(game.Players:GetChildren()) do
if plr.Team.Name == "Playing" then
table.insert(playing, plr.Name)
end
end
if #playing == 0 then
staus.Value = "Everyone Has Died"
wait(3)
break
end
if #playing == 1 then
staus.Value = playing[1].." Has Won The Game!"
for i, plr in pairs(game.Players:GetChildren()) do
if playing[1] == plr.name then
plr.leaderstats.Wins.Value += 1
end
end
wait(3)
break
end
wait(1)
end
wait(3)
end
end
spawn(round)
Explorer: