Script not finding items in game

Hi!
For some reason, my script here should to the following
1: Select a map out of Lighting, and then load it (tp players)
2: Change the text of the UI

For some reason it gets these errors:


What is wrong?

Intermission = 10 
PlayTime = 75 
local text = game.Players.PlayerGui:FindFirstChild("MGDisplay.Frame.GameChosen")


while wait () do
	wait(Intermission) 
	
		Maps = (math.random(1,3)) 
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
		if Maps == 1 then 
text.Text = "6 Blocks"
		map = game.Lighting:FindFirstChild("Map2"):Clone() 
		map.Parent = game.Workspace
		map.Name = "Map"
		map:MakeJoints()
		target = game.Workspace.Map["Spawn1"] 
		for i, v in pairs(game.Players:GetChildren()) do
			wait (PlayTime)
		game.Workspace.Map:remove()
	end 
--4Block
		if Maps == 2 then 

			text.Text = "4 Blocks"
		map = game.Lighting:FindFirstChild("Map1"):Clone()
		map.Parent = game.Workspace
		map.Name = "Map"
		map:MakeJoints()
		target = game.Workspace.Map["SpawnPart"]
		for i, v in pairs(game.Players:GetChildren()) do
		v.Character.Torso.CFrame = target.CFrame + Vector3.new(0,4,0) 
		wait(2)

		end
		wait(PlayTime)
		game.Workspace.Map:remove()
		end 
		--rising lava--
		if Maps == 3 then 

			text.Text = "Rising Lava"
			map = game.Lighting:FindFirstChild("Map3"):Clone()
			map.Parent = game.Workspace
			map.Name = "Map"
			map:MakeJoints()
			target = game.Workspace.Map["Spawn1"] 
			for i, v in pairs(game.Players:GetChildren()) do
				v.Character.Torso.CFrame = target.CFrame + Vector3.new(0,4,0) 
				wait(2)

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

Are you sure that there is a GUI in players? https://csgo-russians.go-get-a.life/qE9xDD

You can find PlayerGui:
First: FindFirstChild()
Second: Write find playerGui after wait()

It should be looking in the current player’s UI folder.

If this is a script than text, you would have to indicate the player instance for example local text = game.Players.Roblox.PlayerGui:FindFirstChild(“MGDisplay.Frame.GameChosen”) if this is a localscript do local text = game.Players.LocalPlayer.PlayerGui:FindFirstChild(“MGDisplay.Frame.GameChosen”)

The text is not my main concern. It’s the fact the map toes not spawn / tp.

That is not whats its doing. Also seeing that you are using a serverscript and not localscript, I would not recommend to mess with the UI using that, cause it is basically impossible to manipulate the UI of one specific player using this method.

Try to get the UI in a localscript and then do game.Players.Localplayer.PlayerGui

image
Yes. I thought it would look in this path, but I guess it’s not.

No, to get this path you need to do game.Players.YourPlayerNameHere.PlayerGui.
But once again, I’d not recommend UI manipulation using a serverscript.

Edit: When using a localscipt you can alternatively do game.Players.LocalPlayer.PlayerGui

Once again,

. Just looking for this now,.

Can you maybe show a screenshot of the Lighting service?
Also, I recommend using ServerStorage to store maps.

image

Did you test the script again? In the console it seems as if you forgot to capitalize the “Map1” and in your script that seems fine.

In your image, the next error says map1, is it a grammatical mistake since the folders have M as capitalized?


microsoft wants broken game


cant believe i left that in, fixing now

wait, where is the grammar error? dont see it

		if Maps == 1 then 
text.Text = "6 Blocks"
		map = game.Lighting:FindFirstChild("Map2"):Clone() 
		map.Parent = game.Workspace
		map.Name = "Map"
		map:MakeJoints()
		target = game.Workspace.Map["Spawn1"] 
		for i, v in pairs(game.Players:GetChildren()) do
			wait (PlayTime)
		game.Workspace.Map:remove()
	end 
--4Block
		if Maps == 2 then 

			text.Text = "4 Blocks"
		map = game.Lighting:FindFirstChild("Map1"):Clone()
		map.Parent = game.Workspace
		map.Name = "Map"
		map:MakeJoints()
		target = game.Workspace.Map["SpawnPart"]
		for i, v in pairs(game.Players:GetChildren()) do
		v.Character.Torso.CFrame = target.CFrame + Vector3.new(0,4,0) 
		wait(2)

		end
		wait(PlayTime)
		game.Workspace.Map:remove()
		end 
		--rising lava--
		if Maps == 3 then 

			text.Text = "Rising Lava"
			map = game.Lighting:FindFirstChild("Map3"):Clone()
			map.Parent = game.Workspace
			map.Name = "Map"
			map:MakeJoints()
			target = game.Workspace.Map["Spawn1"] 
			for i, v in pairs(game.Players:GetChildren()) do
				v.Character.Torso.CFrame = target.CFrame + Vector3.new(0,4,0) 
				wait(2)

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

it’s not in and it still wont spawn

In your screenshot of the console it looked as if you forgot to capitalize the m of “Map1” in your script.
But in the screenshot of the script it looked perfectly fine, so did you test the script again?


Still nothing.

Any errors?------------------------