PlayerGui and StarterGui - Differences

Hello, everyone! I hope you all are having a wonderful day! :person_tipping_hand:

Recently, I was simply making a testing frame within a baseplate at the studio engine, and once scripting for short, my head immediately noticed something…

After making a few lines with the data class type StarterGui, I begin to think: “Wait, why am I using StarterGui? I should’ve used PlayerGui for it!”. One of my latest topics I made under this subcategory had a few individual developers talking about this class PlayerGui and that it would be good to use it… But, the only one thing that breaks my brain is how I can apply it and/or how I can understand the difference between this + StarterGui properly due to lack of information about it…

(Image containing the code of my recent testing frame)

If anyone can help me quite solve this little funny mystery, I would sincerely appreciate it very, but very much!

Thank you!! :grin:

StarterGui. Think of it like a folder that contains GUI. This GUI is cloned to the player from the server on join. PlayerGUI, the Gui on the client’s screen, is what you should be managing instead.

Side note: use task.wait() instead of wait()

Got it, and how do I insert PlayerGui in my script? Because I tried like, making the same things as I did to the “folder” that “cloned” the server’s GUIs and it did not work… XD

Also, another thing to mention is that I usually get confused as well with task.wait() and wait(), so I only apply the old type :melting_face:

You should be doing script.Parent.yourGuiName and you should not need to reference it like that.

1 Like

Got it! Well, I did some modifications as you said and followed the guide, and the result was this:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	print(player.UserId, player.Name, player.DisplayName, " joined the experience")
	
	local TextLabel = script.Parent.Frame
	TextLabel.BackgroundTransparency = 1
	TextLabel.Text = "Loading"
	TextLabel.TextScaled = true
	
	task.wait(5)
	
	for index=0.1,1,1 do
		TextLabel.BackgroundTransparency = index -- It is going to fade the frame background transparency in milliseconds.
		task.wait(0.01)
	end
	
	task.wait(1.75)
	
	print("Loaded.")
	
	local days = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
	
	print("Today is " .. days[5])
end)

(Full code line of the script to understand the situation)

Once making the changes and played at Studio, nothing changed really… Not sure if it is missing other parts to make it 100% functional…

1 Like

To note, it does not show as well in the Output tab, even with the information needed to be printed.

What exactly is the script parented to?

The script is parented to the testing frame (in the previous version, it was “parented” as game.StarterGui.ScreenGui.Frame)

is this a loading screen as soon as the player joins? if so i’d approach it very differently. I don’t think playeradded even properly fires off of a gui when the player itself joins…

Regardless, if you want to access PlayerGui, its right on Player.PlayerGui, inside of playergui itll be structered the exact same as it was in startergui

2 Likes

IIRC (If I Remember Correctly), I made one LocalScript that fired and printed showcasing the player joining and leaving… But, continue further, yes, it is going to appear once the player spawns to the Baseplate!

You see, I tried doing that a bit before making this topic, yet, it gave me errors as it was not having the capacity to track the data class… Although, maybe as an alternative, this can work a bit?

Player gui is what the player sees and the place where changes to gui from scripts happens and Startergui is where you put it to replicate into all those players

I believe I got it in the first responses a bit above as PlayerGui being what the players see through the client and StarterGui restoring to players at the server… Although, I am still having difficulty applying the PlayerGui using the methods script.Parent.Frame + now Players:FindFirstChildOfClass("PlayerGui") above:

everything would be that as they are all children of a player gui

Everything as in for the variables that are parenting the frame, right?

player.LocalPlayer Added doesn’t work that well btw so i suggest detecting it on server then firing a remote which triggers the script

Yeah… I noticed that and immediately modified it! It looks like this now:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	print(player.UserId, player.Name, player.DisplayName, " joined the experience")
	
	local TextLabel = script.Parent.Frame or Players:FindFirstChildOfClass("PlayerGui"):FindFirstChild(script.Parent.Frame)
	TextLabel.BackgroundTransparency = 1
	TextLabel.Text = "Loading"
	TextLabel.TextScaled = true
	
	task.wait(5)
	
	for index=0.1,1,1 do
		TextLabel.BackgroundTransparency = index
		task.wait(0.01)
	end
	
	task.wait(1.75)
	
	print("Loaded.")
	
	local days = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
	
	print("Today is " .. days[5])
end)

Where is this script located if it’s in Starter gui it won’t work?

It is located in StarterGui > ScreenGui… I can try re-locating the LocalScript to somewhere else such as StarterPlayer, yet nothing works.

local Script’s can’t do anything that the server can e.g check when a player is added

So, in this case, I would have to remove the Players.PlayerAdded fire event, right?