Roblox Gui Print

Hello,

So recently I was making a localscript in an frame of a screengui in startergui and what I was trying to make was a script that prints if the frame is visible or not.

I’ve tried searching on google and found nothing.

My script is here:

game.StarterGui.ScreenGui.Frame.Visible = true
if true then
	print ("ScreenGui is visible to players!")
	looped = false
else
	if false then
		print ("ScreenGui is not visible to players!")
		looped = false
	end
end

Sorry if this is easy, I am a beginner scripter and am better at building.

1 Like

Change

if true then

To

if looped == true then

Remove

if false then

And replace the second looped = false to

looped = true

Entire script:

looped = true

game.StarterGui.ScreenGui.Frame.Visible = true
if looped == then
	print ("ScreenGui is visible to players!")
	looped = false
else
	print ("ScreenGui is not visible to players!")
	looped = true
end

Does not work. I tried it but it says the following error: [Players.HDAdminUnofficial.PlayerGui.ScreenGui.Frame.LocalScript:4: Expected identifier when parsing expression, got ‘then’]

And i’m not trying to loop the script. I’m just making it false.

Because after the == you need add something, like if Loop == true then ....

Or too just if Loop then.

1 Like

if true then runs regardless what you do with it and the else is pretty much removed (like any compiler with optimisations turned on).
You’re assigning the Frame in the StarterGui visible property to true, however as it’s a StarterGui and not a PlayerGui, the user will not see it.

Check if the Frame in the PlayerGui of the local player is visible or not by doing if ...Frame.Visible then.

1 Like

Tried it, here’s my script now and it does not work:

game.StarterGui.ScreenGui.Frame.Visible = true

if game.StarterGui.ScreenGui.Frame.Visible then

print ("ScreenGui is visible to players!")

looped = false

else

if game.StarterGui.ScreenGui.Frame.Visible == false then

print ("ScreenGui is not visible to players!")

looped = false

end

end```

First of all is it a localscript second of all put the same code in startergui or make the parent the ui you want to become visible and do script.Parent

1 Like

The script finally worked after some trying.

Here’s the script:


game.StarterGui.ScreenGui.Frame.Visible = false
if game.StarterGui.ScreenGui.Frame.Visible then
	print ("ScreenGui is visible to players!")
	looped = false
else
	if game.StarterGui.ScreenGui.Frame.Visible == false then
		print ("ScreenGui is not visible to players!")
		looped = false
	end
end

I just now know that you have to put it not visible in the script (false) so it will update.

The script needs to reference the ScreenGUI, you do not reference it in the starterGUI since it is cloned to the PlayerGUI. Instead you should do:

local UI = script.Parent --this is different than the one in StarterGUI
local frame = UI:WaitForChild("Frame")

frame.Visible = true --or false
if frame.Visible then
--Do stuff here
else
--Do stuff here
end
1 Like