Basically, it's a survival game, and at the end of the level, it supposed to display the winner, but it won't show! The script is in the server script service. Someone please help!!
while true do
local replicatedstorage = game:GetService('ReplicatedStorage')
local status = replicatedstorage.Status
local mapinserverstorage = game:GetService('ServerStorage'):GetChildren()
local chosenmap = mapinserverstorage[math.random(1, #mapinserverstorage)]
local disasterinreplicatedfirst = game:GetService('ReplicatedFirst'):GetChildren()
local chosendisaster = disasterinreplicatedfirst[math.random(1, #disasterinreplicatedfirst)]
local mapstorage = game.Workspace:WaitForChild('mapstorage')
local disaterstorage = game.Workspace:WaitForChild('disaster')
for i = 3, 0, -1 do
status.Value = "Game will start in "..i
wait(1)
end
wait(0.5)
status.Value = 'The map will be '..chosenmap.Name
wait(2)
status.Value = 'Get ready'
wait(0.1)
status.Value = ''
chosenmap:Clone().Parent = mapstorage
for p = 20, 0, -1 do
status.Value = 'You will be teleported in '..p
wait(1)
end
_G.players = {}
for i, v in pairs(game.Players:GetPlayers()) do
if v then
table.insert(_G.players, v.Name)
end
end
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))
wait(0.1)
end
end
end
wait(2)
status.Value = 'Prepare...'
wait(0.9)
status.Value = 'The world will end by...'
wait(0.3)
status.Value = chosendisaster.Name
wait(0.3)
chosendisaster:Clone().Parent = disaterstorage
for p = 5, 0, -1 do
wait(1)
status.Value = p.." Seconds Left To Survive!"
end
if status.Value == '0 Seconds Left To Survive!' then
mapstorage:ClearAllChildren()
disaterstorage:ClearAllChildren()
status.Value = 'Game over!!'
wait(2)
if #_G.player == 1 then
for i, v in pairs(_G.players) do
if v ~= nil then
status.Value = v..' has survived and get 100 points!'
break
end
end
break
end
end
end

5 comments
why are you using the global table. is it used in multiple scripts
i was using a alvinblox tutorial
You don't require the _G global thingy anymore; you can use ModuleScripts instead, which have more advantages, as for example, it can be used by both server-sides & client-sides.
uhh im kinda still new to modules, wold you mind showing me the script i would use?
Here's a document on ModuleScripts: http://wiki.roblox.com/index.php?title=API:Class/ModuleScript