Gui enabling visually but is not in scripts/explorer

Hello! Thank you for reading my post. I am trying to make a “work” system and I am struggling to have the gui work. I do not know if it is a scripting error or something else so I am going to assume it is a scripting error. When my script to open the gui is run, the gui will show up but if I go into the explorer and go to the gui, then enabled, it says Enabled = false. In later scripts, if I do something to check if it is enabled, it will show false even though I can see it. My goal is to have the “WorkImage” display different images as you do the work. Here is the scripts:

Local script to open gui:

local Player = game.Players.LocalPlayer
local ScreenGui = Player.PlayerGui:WaitForChild("ScreenGui")
local Computor = game.Workspace.Computor
local Screen = Computor:WaitForChild("Screen")
local CD = Screen.ClickDetector

CD.MouseClick:Connect(function()
	ScreenGui.Enabled = true
end)

Local script controlling to images shown:

print("Started")
local plr = game.Players.LocalPlayer
local ScreenGui = plr.PlayerGui.ScreenGui
local MainFrame = ScreenGui.MainFrame
local WorkFrame = MainFrame.WorkFrame
local WorkImage = WorkFrame.ImageLabel
local ValidOptions = WorkImage.ValidOptions
local InvalidOptions = WorkImage.InvalidOptions
local CorrectAnswer = "nil"
print("Finished Variables")

while true do
	if ScreenGui.Enabled == true then
		print("Entered Loop")
		local random = math.random(1,2)
		if random == 1 then
			WorkImage.Image = ValidOptions:GetChildren()[math.random(1, #ValidOptions:GetChildren())].Value
			CorrectAnswer = "Yes"
			print("Valid")
		else
			WorkImage.Image =  InvalidOptions:GetChildren()[math.random(1, #InvalidOptions:GetChildren())].Value
			CorrectAnswer = "No"
			print("Invalid")
		end
		wait(10)
	end
	wait(0.1)
end

All help is appreciated! Thank you for reading this and I hope you can come up with a solution for my problem!

1 Like

hi there! I’m curious about how you are checking in the explorer to see if the gui is false. Please make sure you go to the tab “test” and click the button that changes it from server to client, then check the screenGui again.

Do you mean a local server test in the “test” section? If so it is still false in a local server test

I mean when you playtest the game, click the “test” tab and click the green button that says “server” then check the screen gui.

But I just remembered that the gui is put into the player object. So you have to check that instead of StarterGui. Go in the explorer, click “Players” then your name folder, then PlayerGui. Check the gui there.

1 Like

You need to go into the players player gui as the other post suggested

Oh! Yes it is enabled but the part to show the image does not work, it just goes white when the script gets to that part, any ideas why?

1 Like

I’m not sure which part you’re referring to? It would be nice to know more.

I have the different decal ids in a folder which is in the imagelabel.
This part of the script:

WorkImage.Image = ValidOptions:GetChildren()[math.random(1, #ValidOptions:GetChildren())].Value

Is the section that is supposed to set the image to something within one of the folders. Instead, it just goes white with no error message. Any idea why this could be happening. Also, when I check it in explorer it still says it is the place holder image. (in client too)

1 Like

Do you for sure have images set to each imagelabel in the folder?

They are all string values which are in a folder which are in the imagelabel. They are all in one image label. The script is supposed to choose one at random and make that the image that is shown.

I believe you are storing the image URLs in the StringValues? I’ll have to check in studio to be sure, but you’ll likely have to set the image URL, and not the image of the ImageLabel.

1 Like

sorry, it appears I was wrong. image is the same as and using the URL

I am storing the image ids in the string values. Is this an issue?

Looking it over thoroughly, I really don’t see anything wrong with your code. Could you send a screenshot of the game?

Do you mean what happens in the game or what it looks like in the explorer?

Here is the game + explorer:

Are you getting the “valid” or “invalid” messages in the output?

It changes every game, as it is a 50/50 chance for either

fyi, the script does not stop and still constantly runs while the gui is open, the only problem is the visual gui

Sorry, I really am not sure what the issue is. I would check to see if any gui objects are overlapping the image label and check that the images in the asset manager are indeed valid and loaded there, or load before the test. I would check to make sure that ValidOptions:GetChildren()[math.random(1, #ValidOptions:GetChildren())].Value is producing the desired result.

There is nothing in asset manager > images
Is this normal?