The game was working prior to me adding in the code to tell who the winner was. Once I added it in, it started to break.
local replicatedstorage = game:GetService('ReplicatedStorage')
local status = replicatedstorage:WaitForChild('InfoValue')
local mapstorage = game.Workspace:WaitForChild('MapStorage')
while true do
--[[while game.Players.NumPlayers < 2 do
status.Value = 'There Needs To Be 2 Or More Players To Begin'
repeat wait(2)until game.Players.NumPlayers >= 2
end
]]
for i = 15,0,-1 do
status.Value = 'Intermission '..i
wait(1)
end
_G.gameplayers = {}
for i, v in pairs(game.Players:GetPlayers()) do
if v then
table.insert(_G.gameplayers, v.Name)
end
end
local mapinserverstorage = game:GetService('ServerStorage'):GetChildren()
local chosenmap = mapinserverstorage[math.random(1, #mapinserverstorage)]
chosenmap:Clone().Parent = mapstorage
status.Value = ('Get ready to get teleported!')
wait(3)
local spawns = chosenmap:WaitForChild('Spawns'):GetChildren()
for _, player in pairs(game.Players:GetPlayers()) do
if player and #spawns > 0 then
local torso = player.Character:WaitForChild('Torso')
local allspawns = math.random(1, #spawns)
local randomspawn = spawns[allspawns]
if randomspawn and torso then
table.remove(spawns, allspawns)
torso.CFrame = CFrame.new(randomspawn.Position + Vector3.new(0,2,0))
local sword = game.ReplicatedStorage.woodSword
local newSword = sword:Clone()
newSword.Parent = player.Backpack
end
end
end
for i = 180, 0, -1 do
wait(1)
if #_G.gameplayers == 1 then
for i, v in pairs{_G.gameplayers} do
if v ~= nil then
status.Value = v.. ' is the winner~'
game.Players[v].leaderstats.Points.Value = game.Players[v].leaderstats.Points.Value + 10
break
end
end
break
else
status.Value = i..' seconds remaining!'
end
end
--[[for i = 180, 0, -1 do
if i == 0 then
status.Value = 'Game Set!'
break
end
wait(1)
if #_G.gameplayers == 1 then
for i, v in pairs(_G.gameplayers) do
if v ~= nil then
status.Value = v..' is the winner!'
break
end
end
break
else
status.Value = i.. ' seconds remaining!'
end
end
]]
--wait(30)
mapstorage:ClearAllChildren()
--wait(1)
wait(5)
end

1 comment
Help us to help you; give us more info.