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!
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.
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.
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)
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.
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.