Minigame selector not working in Roblox Servers

Hi!
My script for Minigame Selection for some reason only works in studio.
(for some reason as soon as I started making this thread it broke completely. It only broke when I disabled it for like 5 mins for testing.
Studio:
image
InGame:
image (did not TP me)

Code:


Intermission = 30
PlayTime = 90 


while true do
	wait(Intermission) 

	Maps = (math.random(1,3)) 
	
	if Maps == 1 then
			map = game.Lighting:FindFirstChild("Map2"):Clone() 
		map.Parent = game.Workspace
		map.Name = "Map"
		target = game.Workspace.Map["Spawn1"] 
		for i, v in pairs(game.Players:GetChildren()) do
			print "6block spawned!"
			v.Character:WaitForChild("HumanoidRootPart").CFrame = target.CFrame + Vector3.new(0,4,0)
			wait (PlayTime)
			game.Workspace.Map:remove()
			print "6block despawned!"
		end 	
		
	elseif Maps == 2 then
				map = game.Lighting:FindFirstChild("Map1"):Clone()
			map.Parent = game.Workspace
			map.Name = "Map"
			target = game.Workspace.Map["SpawnPart"]
		for i, v in pairs(game.Players:GetChildren()) do
			print "4block spawned!"
			v.Character:WaitForChild("HumanoidRootPart").CFrame = target.CFrame + Vector3.new(0,4,0)
			print "4block teleported!"
				wait(2)

			end
			wait(PlayTime)
		game.Workspace.Map:remove()	
		
	elseif Maps == 3 then
				map = game.Lighting:FindFirstChild("Map3"):Clone()
			map.Parent = game.Workspace
			map.Name = "Map"
			target = game.Workspace.Map["Spawn1"] 
		for i, v in pairs(game.Players:GetChildren()) do
			print "risinglava spawned!"
				v.Character:WaitForChild("HumanoidRootPart").CFrame = target.CFrame + Vector3.new(0,4,0)
				wait(2)

			end
			wait(PlayTime) 
			game.Workspace.Map:remove()
		end 	
	end

Console:

Intermission = 30
PlayTime = 90 

while true do
	wait(Intermission) 

	Maps = (math.random(1,3)) 
	
	if Maps == 1 then
			map = game.Lighting:FindFirstChild("Map2"):Clone() 
		map.Parent = game.Workspace
		map.Name = "Map"
		target = game.Workspace.Map["Spawn1"] 
		for i, v in pairs(game.Players:GetChildren()) do
			print "6block spawned!"
            repeat wait() until v.Character
			v.Character:WaitForChild("HumanoidRootPart").CFrame = target.CFrame + Vector3.new(0,4,0)
			wait (PlayTime)
			game.Workspace.Map:remove()
			print "6block despawned!"
		end 	
	elseif Maps == 2 then
				map = game.Lighting:FindFirstChild("Map1"):Clone()
			map.Parent = game.Workspace
			map.Name = "Map"
			target = game.Workspace.Map["SpawnPart"]
		for i, v in pairs(game.Players:GetChildren()) do
			print "4block spawned!"
			repeat wait() until v.Character
            v.Character:WaitForChild("HumanoidRootPart").CFrame = target.CFrame + Vector3.new(0,4,0)
			print "4block teleported!"
				wait(2)

			end
			wait(PlayTime)
		game.Workspace.Map:remove()	
		
	elseif Maps == 3 then
			map = game.Lighting:FindFirstChild("Map3"):Clone()
			map.Parent = game.Workspace
			map.Name = "Map"
			target = game.Workspace.Map["Spawn1"] 
		for i, v in pairs(game.Players:GetChildren()) do
			print "risinglava spawned!"
			repeat wait() until v.Character
            v.Character:WaitForChild("HumanoidRootPart").CFrame = target.CFrame + Vector3.new(0,4,0)
			wait(2)
			end
			wait(PlayTime) 
			game.Workspace.Map:remove()
		end 	
	end

Nope.

Are you sure that the script is related to the one you are editing right now?

Yes. What do you mean? i have the minigame selection/

Have you added anything else that is not a player in game.Players?

Make sure that you haven’t added anything in this service:
Because the code says that there is a cloned or a placed object called Atmosphere in there.
image

Fixed it. Turns out I left “Atmosphere” in it when I tried to place it out temp for testing.

2 Likes

If you have no objects in the Players folder then try this:

Intermission = 30

PlayTime = 90

while true do
wait(Intermission)

Maps = (math.random(1,3)) 

if Maps == 1 then
		map = game.Lighting:FindFirstChild("Map2"):Clone() 
	map.Parent = game.Workspace
	map.Name = "Map"
	target = game.Workspace.Map["Spawn1"] 
	for i, v in pairs(game.Players:GetChildren()) do
		print "6block spawned!"
                    pcall(function(
		v.Character:WaitForChild("HumanoidRootPart").CFrame = target.CFrame + Vector3.new(0,4,0)
		end)
                    wait (PlayTime)
		game.Workspace.Map:remove()
		print "6block despawned!"
	end 	
elseif Maps == 2 then
			map = game.Lighting:FindFirstChild("Map1"):Clone()
		map.Parent = game.Workspace
		map.Name = "Map"
		target = game.Workspace.Map["SpawnPart"]
	for i, v in pairs(game.Players:GetChildren()) do
		print "4block spawned!"
		pcall(function(
        v.Character:WaitForChild("HumanoidRootPart").CFrame = target.CFrame + Vector3.new(0,4,0) 
                    end)
		print "4block teleported!"
			wait(2)

		end
		wait(PlayTime)
	game.Workspace.Map:remove()

Also don’t forget to close the page.

Don’t delete it just close it. There is a tick box that you should find.