Playergui is not an valid member of players "Players"

Hello, there is an problem with my script!

My Goal I am trying to make an sequel to an game i made, this is basically just an tech demo of stuff i randomly make, and its for my friend!

But, Theres an huge problem…

Scripted, etc. [spoiler](poop overloaded sus amogus 2020[spoiler]
And that, the error says this:


But, playergui is an thing for Player = game.Getservice.

Do not reply if your not going to actually help.

local Player = game:GetService("Players")
--changed to Player instead of players--
--player not playres--
--workspace.w
workspace.Wubbox.Head.ProximityPrompt.Triggered:Connect(function(plr)
	--script.Parent.scree
	--game.PlayerGui.StarterGui.Frame.Enabled
	--player
	Player.PlayerGui.ScreenGui.Frame.Visible = true
	wait(1)
	Player.PlayerGui.ScreenGui.Frame.TextLabel.Text = "Hello"
	local text = Player.PlayerGui.ScreenGui.Frame.TextLabel.Text
	--text = "
	wait(2)
	--had to add wait(2)
	text = "Hello there"
	wait(2)
	text = "I see you are new here, this is an building."
	wait(2)
	text = "This is an high building, not going to lie, what brings you here?"
	wait(2)
	text = "Watching birds? nice... bit weird but ok.."
	wait(4)
	text = "Anyways, You mind going to the ledge of the building for one sec?"
	wait(2)
	text = "Hehe... i wont budge..."
	wait(2)
	text = "You wont? ok, whatever."
	wait(2)
	text = "Well..."
	wait(2)
	text = "You know the traffic cone man?"
	wait(2)
	text = "He's gone..."
	wait(2)
	text = "Also, thanks for saving me from that monster... some of it is still in me, thats why i said go to the ledge, the monster was trying to push you off suspicous right!"
	wait(2)
	text = "Traffic cone, man got shot 12 times in the street, of new york"
	wait(2)
	text = "This is new york by the way!"
	wait(2)
	text = "Anyways, Theres something weird on another building its close"
	wait(1)
	--had to add wait(1)
	text = "You think you can do some parkour?"
	--wait
	--(2)
	wait(2)
	--s
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.9
	wait(2)
	--was going to -- this but eh--
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.8
	wait(0.5)
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.7
	wait(0.5)
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.6
	wait(0.5)
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.5
	wait(0.5)
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.4
	wait(0.5)
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.3
	wait(0.5)
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.2
	wait(0.5)
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.1
	wait(0.1)
	wait(1)
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.
	wait(5)
	game.PlayerGui.ScreenGui.TextLabel.Text = "Let's begin.."
	wait(2)
	game.PlayerGui.ScreenGui.TextLabel.Visible = false
end)
1 Like

In line 1 you put:

local Player = game:GetService("Players")

Are you trying to get the local player? If so just change the line to

local Player = game:GetService("Players").LocalPlayer

But its serverwide, everybody needs to see it or it’ll wreck the game.

Oh, just loop through the players using :GetPlayers to get each individual player.

e.g.

for i,Player in pairs(game:GetService("Players"):GetPlayers()) do
 --<whatever your function is>
end

Also I can see towards the end of your code snippet you reference

game.PlayerGui

??? Might wanna fix that up to Player.PlayerGui

you should really be using for loops for this
tables should be used for the text part

https://education.roblox.com/en-us/resources/repeating-tasks-with-for-loops

no Players is a service and PlayerGui isn’t a child of Players
it would be game.Players.PlayerName.PlayerGui
the PlayerName being the name of the player

if player is already defined you can do Player.PlayerGui

i don’t have an fuction this is proximtiy prompts, and do i replace that with the local Player = game:Getservice(players)

Adding into this here is an actual example:

--Table loop
local Dialogue = {
	"Hello!",
	"My name is Alpha",
	"I'm a programmer."
}

for i, v in pairs(Dialogue) do
	TextLabel.Text = v
	wait(2)
end

--Tween transparency
local TweenService = game:GetService("TweenService")
TweenService:Create(TextLabel, TweenInfo.new(5), {Transparency = 0}):Play()

I provided a basic example for tweening but you can use more parameters of your choice to make it nicer within TweenInfo()

2 Likes

So when the ProximityPrompt is triggered, you want to loop through all the players and change the GUI for each player. Like so:

local Players = game:GetService("Players")
workspace.Wubbox.Head.ProximityPrompt.Triggered:Connect(function(plr)
    for i,Player in pairs(Players:GetPlayers()) do
	--script.Parent.scree
	--game.PlayerGui.StarterGui.Frame.Enabled
	--player
	Player.PlayerGui.ScreenGui.Frame.Visible = true
	wait(1)
	Player.PlayerGui.ScreenGui.Frame.TextLabel.Text = "Hello"
	local text = Player.PlayerGui.ScreenGui.Frame.TextLabel.Text
	--text = "
	wait(2)
	--had to add wait(2)
	text = "Hello there"
	wait(2)
	text = "I see you are new here, this is an building."
	wait(2)
	text = "This is an high building, not going to lie, what brings you here?"
	wait(2)
	text = "Watching birds? nice... bit weird but ok.."
	wait(4)
	text = "Anyways, You mind going to the ledge of the building for one sec?"
	wait(2)
	text = "Hehe... i wont budge..."
	wait(2)
	text = "You wont? ok, whatever."
	wait(2)
	text = "Well..."
	wait(2)
	text = "You know the traffic cone man?"
	wait(2)
	text = "He's gone..."
	wait(2)
	text = "Also, thanks for saving me from that monster... some of it is still in me, thats why i said go to the ledge, the monster was trying to push you off suspicous right!"
	wait(2)
	text = "Traffic cone, man got shot 12 times in the street, of new york"
	wait(2)
	text = "This is new york by the way!"
	wait(2)
	text = "Anyways, Theres something weird on another building its close"
	wait(1)
	--had to add wait(1)
	text = "You think you can do some parkour?"
	--wait
	--(2)
	wait(2)
	--s
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.9
	wait(2)
	--was going to -- this but eh--
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.8
	wait(0.5)
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.7
	wait(0.5)
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.6
	wait(0.5)
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.5
	wait(0.5)
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.4
	wait(0.5)
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.3
	wait(0.5)
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.2
	wait(0.5)
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.1
	wait(0.1)
	wait(1)
	game.PlayerGui.ScreenGui.TextLabel.Transparency = 0.
	wait(5)
	game.PlayerGui.ScreenGui.TextLabel.Text = "Let's begin.."
	wait(2)
	game.PlayerGui.ScreenGui.TextLabel.Visible = false
    end
end)

Also I recommend following @alphajpeg’s advice and using a table to store the text strings. It’s a lot easier to code and read.

New error,


weird

workspace.Wubbox.Head.ProximityPrompt.Triggered:Connect(function(plr)

new error again after i fixed it

Can you send the code on line 10?

30char

for i, Player in pairs(Players:GetPlayers()) do

Make sure to add :GetPlayers() to get the players.

2 Likes

Feel like @yasir10001 answer should of been marked as solution though thanks anyways.

you can’t loop through a service, which is why this errors

Looping through the players in one script is a bad idea. It will go to each individual player and wait for each of them. Instead, you should connect the proximity prompt to a server script which fires a remote event.
In this example I have a remote event name playerText in ReplicatedStorage.

Client

local player = game:GetService('Players').LocalPlayer
game.ReplicatedStorage.playerText.OnClientEvent:Connect(function()
	--gui stuff
end)

Server

workspace.Wubbox.Head.ProximityPrompt.Triggered:Connect(function()
        game.ReplicatedStorage.playerText:FireAllClients()
end)

wait i hav e another problem, this is related.


when i make the local script, for the text it does this, as i don’t wanna change my script in huge ways

:GetPlayers() works on the client and server…

Also here you wrote image “Player:GetPlayers()” and I’m guessing the Player variable is the LocalPlayer and :GetPlayers() isnt a function of LocalPlayer so make sure to use the Players service cause that’s what it is apart of.