This is quite frankly what I stated in the title. I’m trying to reference an image button in my game to set it’s visibility on and off through commands but when I do “game.StarterGui.SettingsMenu.Open1.v” nothing pops up to shop visibility is an option “Open1 is the button’s name”. If I fill in “game.StarterGui.SettingsMenu.Open1.visible” nothing happens either. This isn’t because my script is wrong, roblox isn’t letting me reference the image button. What do I do?
-
Its not
StarterGui
, ItsLocalPlayer.PlayerGui
-
Its
Visible
, the V is capitalized, and the rest lowercase. -
If the Property does not exist, you are likely not typing it correctly, or you arent Looking at the Correct item.
-
You cannot reference a Property as all that will do is give you its value, Instead you will have to Reference the
Instance
holding the Property, and change if from there.
What is your code for changing the property?
I am 100% typing it correctly and looking at the correct item. Also it doesn’t even show LocalPlayer as a function in this script and won’t “let” my type it. I know it’s Visible, that’s what I already tried. I can reference this if it’s a frame but it won’t let me if it’s an image button
I’m just referencing it, for example game.StarterGui.SettingsMenu.Open1.Visible = true. Although it doesn’t show visible as an option
You are probably not typing it correctly and looking at the correct item, as is evident by the fact that it does not work.
Try adding --!strict
on the top of the script to enable strict type checking.
StarterGui and PlayerGui are different. PlayerGui is cloned from StarterGui, just like how Backpack is cloned from StarterGear.
Assuming you’re using a Server-side script on GUI elements, it’s best to use LocalScript for this instead of regular ones because it’s supposed to happen on client, not on the server.
also
here’s how it should be
local playerSV = game:GetService("Players")
local client_player = playerSV.LocalPlayer
local playerGUI = client_player.PlayerGui
-- please atleast create variable, don't straight up merging them from "game.Players..."
This description of your problem is a bit vague, can you post the entire section of your code that isn’t working? I am assuming that your problem lies elsewhere than the singe line you provided in the original post.
That does enable referencing the player’s GUI but it still doesn’t fix the current issue of not being able to reference the image button’s visibility. If I put the button in a frame I can reference the frame’s visibility but the image button won’t actually work when it’s located in a frame.
It doesn’t lie in a separate line of code. I created a test script all by it’s self to try and reference the button’s visibility to be off but it just won’t let me change the button’s visibility through a script.
I’m typing it correctly. It lets me reference the visibility of a frame but not an image button and I need to figure out a way to reference the button’s visibility.
If you are typing it correctly, then the problem more than likely lies in a different line of code. Put a print on the line directly before the one that you suppose is giving you issues and see if it outputs.
“I created a test script all by it’s self to try and reference the button’s visibility” So that’s literally all there is. Also, I can easily reference visibility for frames but not for image buttons which is what I need.
Hmmm. Are you sure you’re checking the visibility of the image button in the StarterGui as is referenced in the code and not the one that would be found in the PlayerGui? I can only assume this has something to do with the issue your having. 9 times out of 10 these types of problems are caused just by some simple user error. Have you tried at all to reference it from the PlayerGui? Make sure to try that especially so if your running this off a local script.
I’ve tried PlayerGui and StarterGui and it is a local script. Is it impossible to change the visibility of an image button? Because I can easily change vis for a frame.
Also, if I move it to workspace it lets me reference visibility but I need to reference it through startergui
imageButton.Visible = false
idk what you’re doing but this works fine…
where is the script located?
Im having the exact same issue but with scrolling frames
it’s in StarterGuil, it works if I locate it in somewhere else but then the button doesn’t actually load
You can’t put a LocalScript
in StarterGui
and expect the GUI to load the same time as the script. Use WaitForChild
instead of the dot operator for the first reference to the button.
Plus, this is scripting support but you literally showed no code this entire time…