Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

PlayerGui is not a valid member of Player?

SL : is a screen gui!

Error : PlayerGui is not a valid member of Player? Can someone fix it and repost entire script? Thanks :)

Script made by roblox and edited by me :

local oldMessage = ""
local minPlayers = 2
 
function teleportAllPlayers()
	local target = CFrame.new(workspace.BrickYouTeleportTo.TeleportTarget.Position)
	for i, player in ipairs(game.Players:GetChildren()) do
		player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0)
		player.Playing.Value = 1
		
		for _, child in pairs(game.Players:GetChildren())do
			child.Team = game.Teams:WaitForChild("Alive");
		end
		--add an offset of 5 for each character
	end
end
 
function message(message)
	if oldMessage ~= message then
		oldMessage = message
		print(message)
	end
end
 
function playersCurrentlyPlaying()
	for i, player in ipairs(game.Players:GetChildren()) do
		if player.Playing.Value == 1 then return true end
	end
	return false
end
 
game:GetService('Players').PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		character:WaitForChild("Humanoid").Died:connect(function()
			player.Playing.Value = 0
		end)
	end)
 
	local playing = Instance.new("IntValue", player)
	playing.Value = 0
	playing.Name = "Playing"
end)
 
 
while(true) do
	wait(2)
	for _, localPlayer in pairs(game.Players:GetChildren())do
		if #game.Players:GetPlayers() >= minPlayers then
			if playersCurrentlyPlaying() then
				message("Waiting for the current game to end...")
				localPlayer.Player:WaitForChild('PlayerGui').TL.TextLabel.Text = "Waiting for the current game to end..."
			else
				message("There are enough players for a new game!  Teleporting...")
				localPlayer.Player:WaitForChild('PlayerGui').TL.TextLabel.Text = "There are enough players for a new game!  Teleporting..."
				wait(5)
				teleportAllPlayers()
			
			end
		else
			message("Waiting for more players...")
			localPlayer.Player:WaitForChild('PlayerGui').TL.TextLabel.Text = "Waiting for more players..."
		end
	end
end

10 comments

0

Can you fix it please? I won't be able to help.

0

Not reposting the entire script when it's not in a codeblock. And chances are, the script is running before the playerGui has loaded in. Use Player:WaitForChild('PlayerGui')

0

@Ult I did as you say but now it's saying "Player is not a valid member of Player"

0

What line?

0

@Ult fixed, can you please repost it! ()

0

It doesn't say what line I just pressed f9 in game, the script runs perfectly on studio play mode but not in real play mode!

0

It should still have a line in the developer console.

0

? ^ whats that mean?

0

Nevermind. Let me answer it

0

^ ty

1 answer

Your issue is every line with something like localPlayer.Player:WaitForChild('PlayerGui'). In your for loop, localPlayer IS a Player. So therefore, you're trying to find 'Player' inside a player, which, of course, doesn't exist. I haven't thoroughly checked through, but for your answer, it should be fixed if localPlayer.Player:WaitForChild('PlayerGui') becomes localPlayer:WaitForChild('PlayerGui').

Thanks,

Explosion

2 comments

0

TL is not a valid member of playergui??

0

Are you certain that you've got something named TL in StarterGui...?

This discussion is preserved as it was. New answers, comments, and votes are closed.