Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do i make my ImageLabel Visible and not Visible using a variable?

Asked by
6AGU6 0
4 years ago

so I'm a noob at coding like literally. i figured out how to manually visible and not visible the Image Label, but i need help figuring out how to code it visible and not visible. I'm probably completely wrong but here's the script i tried

if Emotion = ("Happy") then select(Visible) = true

else select(Visible) = false

end

i don't actually know what "select" means.

i hope you guys can help, because I've heard a lot of good things about this website!

0
I recommend that you quickly learn the basics by watching tutorials. Other than that, I see that you've already got some answers trying to help you. AntiWorldliness 868 — 4y

3 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago
if Emotion == ("Happy") then
    script.Parent.Visible = false --you could make this true instead if you wanted
end

script.Parent goes from the script you are coding in, up to whatever it is parented to. So say you have a script inside an image button. By saying script.Parent you are going from the script that you are coding in, to the image button, which is the parent.

Once you have told the game that you want what the script is parented to, you change the property of that by saying .Visible after script.Parent

You simply change the value of the property, and in this case, Visible is a bool property. This means it can only be changed to true/false. = false will make it not visible, or = true would make it visible.

Also, with if statements, you must use two equal signs as == means equal to, while = just changes a value.

I hope this helps, and good luck on your journey to scripting :)

Ad
Log in to vote
0
Answered by 4 years ago

I don't think I've heard of select used in Roblox scripting, but then again, I'm also somewhat of a beginner of scripting. I'm assuming "select" is what your GUI is called. Also, you need to make sure that whenever you're using an if statement, you would need to put two equal signs instead of one. Here's your example:

if Emotion == ("Happy") then -- Double equal signs mean that it's equal to, a single equal sign wouldn't work.
    else select.Visible = false
end

I'm not really sure if this is what you were looking for, but I hope you find an answer! Also, a really good resource is developer.roblox.com, it gives me so much resources. If you need to find the properties of a GUI and how they function, just search up GUI in that website and it should really help you wit GUIs. Hope I helped.

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

So assuming you have the label or whatever you wanted to be visible and not visible is in the starter GUI.

If that is a local script:

You want to get the player so that you can access their PlayerGui. Because that is the place where the stuff in starterGui goes when a player spawns.

So here’s how you would get the player in a local script:

local player = game.Players.LocalPlayer

So the “.” Pretty much means Whatever is inside the thing before the period. So Players are inside game and your LocalPlayer (which is actually you if you joined the game) is inside the folder Players.

When you say

local blah

That pretty much means you are declaring a variable. And variables hold values or paths. So like how I said local player = the path of the player. A variable can be named anything you want, not just “blah”.

A path is where you went to get to them in the files. So you went from game to Players to LocalPlayer.

So next thing you need to do is declare your Label. If this script is inside the label or button or whatever you had, then you can say

local labelBlah  = script.Parent

So since the script is inside the label you can say script.Parent. “.Parent” means whatever the thing before the period is inside is the parent. So if you put a brick inside the label the bricks parent would be the label. If you put a script inside the brick, the scripts parent would be the brick.

If the localscript is not inside the label then you would get the labels path by saying

local label = player.PlayerGui.ScreenGui.label

Since you have the player, and PlayerGui is inside the player, and ScreenGUI is inside PlayerGui and label is inside screen GUI.

Now to make the label visible or not

label.Visible = false
label.Visible = true

Since Visible is a property inside label you would say label.Visible. And true means it can be seen and false means it can’t.

Also screen GUI is something you need to hold the label.

Hope this helped you!

0
It’s important to note that if you changed the name of the label or the screen GUI then you would have to put the replace the name in the path. So if your labels name was YEET then you would say player.PlayerGui.ScreenGui.YEET SethHeinzman 284 — 4y
0
If this was helpful please don’t hesitate to hit the up arrow! If you have questions just ask by commenting on this. SethHeinzman 284 — 4y

Answer this question