So basically, I have this piece of code:
local desc = game.StarterGui.Collection.Description desc.ImageLabel.Visible = false desc.ImageLabel.Image = 1 script.Parent.MouseButton1Down:Connect(function() desc.Active = true desc.Visible = true desc.ImageLabel.Image = script.Parent.Image desc.ImageLabel.Visible = true desc.ImageLabel.Active = true if desc.ImageLabel.Image == script.Parent.Image then print("Image success!") else print("Image failed.") end if desc.ImageLabel.Visible == true then print("Visible success!") else print("Visible failed.") end end)
And in the Workspace, it's like this:
Collection (ScreenGui) CollectionScreen (Frame) c1 (ImageButton) LocalScript (the piece of code above) Description (Frame) ImageLabel (ImageLabel)
The ScreenGui is in PlayerGui btw.
When I playtest the game, the output says "Image success!" and "Visible success", but has no visual effect. I went into the ImageLabel, and Visible and Active are both true. I tried unticking and reticking them, but it still has no visual effect. Its parent is active and visible too. I have even tried changing the Zindex, but again, doesn't work. It seems to be only viewable in the Editor. Can anybody help? Thanks!
You are attempting to make changes through the StarterGui
, which is only responsible for replicating GUIs to the clients. If you want to make changes to a GUI and for the player to actually see these changes, you need to access the GUI from the PlayerGui.
In order to obtain the PlayerGui you must obtain it by using Player.PlayerGui after obtaining the Player.
In your case, it seems that you are using a LocalScript
, so it'd be as easy as doing
local Player = game:GetService("Players").LocalPlayer
Afterwards, obtaining the wanted GUI from the PlayerGui, in your case desc
or Description
.
Putting all of that together your code should look like this:
local Player = game:GetService("Players").LocalPlayer local PlayerGui = Player:WaitForChild("PlayerGui") -- Changed to WaitForChild as you are trying to make immediate changes to this GUI local desc = PlayerGui.Collection:WaitForChild("Description") desc.ImageLabel.Visible = false desc.ImageLabel.Image = 1 script.Parent.MouseButton1Down:Connect(function() desc.Active = true desc.Visible = true desc.ImageLabel.Image = script.Parent.Image desc.ImageLabel.Visible = true desc.ImageLabel.Active = true if desc.ImageLabel.Image == script.Parent.Image then print("Image success!") else print("Image failed.") end if desc.ImageLabel.Visible == true then print("Visible success!") else print("Visible failed.") end end)
Hope this helps you!