It works completely in studio but not Online It teleports one player and then the complete Script stops

local replicatedstorage = game:GetService('ReplicatedStorage')
local status = replicatedstorage:WaitForChild('InfoValue')
local mapstorage = game.Workspace:WaitForChild('mapStorage')

while true do
	while game.Players.NumPlayers < 1 do
		status.Value = 'There needs to be 4 or more players to begin'
		repeat wait(2) until game.Players.NumPlayers >= 1
	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 mapsinserverstorage = game:GetService('ServerStorage'):GetChildren()
	local choosemap = mapsinserverstorage[math.random(1, #mapsinserverstorage)]
	choosemap:Clone().Parent = mapstorage
	status.Value = 'Get ready to get Teleported'
	wait(3)
	local Chosen = math.random(#_G.gameplayers)
	local spawns = choosemap:WaitForChild('Spawns'):GetChildren()
	for i, 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))
				if Chosen == i then
					local sword = game.ReplicatedStorage.Weapon
					local NewSword = sword:Clone()
					NewSword.Parent = player.Backpack
					player.CameraMode = "LockFirstPerson"
				end
			end
		end
	end
	local number = game.ReplicatedStorage.Value.Value
	for i = 240, 0, -1 do
		if i == 0 then
			status.Value = 'Times up!'
			break
		end
		wait(1)
		if #_G.gameplayers == number 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 .. ' secconds remaining'
		end
	end
	mapstorage:ClearAllChildren()
	wait(1)
end

1 comment

0

If you have FE enabled a quick studio test will still run with it off. To test if it works with FE click the start button near the blue test button and it will run everything with FE enabled.