Hello,
I'm self-learning how to use a script that defines the function then uses it. I know some basics but I'm trying to perfect it. But I try this script, but it doesn't work.
local button = script.Parent
local chosen = false
function Chosen()
if chosen == false then
button.TextTransparency = 0
elseif chosen == true then
button.TextTransparency = 1
end
end
button.MouseButton1Click:Connect(Chosen)
What i'm trying to do is basically when you press a text button, the button.TextTransparency = 0, but that's if they haven't already chosen it. I'm making a choice selection GUI, so you pick a choice and then press a button to make the GUI disappear.
You press a text box that you have picked, and the text "Chosen" will come up. I have set the transparency the text to 1, so it can be set to zero. I then I have a variable called "local chosen = false" (basically meaning that it has not been chosen yet, but when it is chosen, the value will be set to true.
The issue is that once when I have pressed the option, it says "Chosen", and when I press it again, the text transparency is 1. This part is okay so far but the issue is when I press the button again, the text transparency does not change, but I want it to.
I'm guessing that some sort of loop might have to be set up to make sure this function occurs again and again.
How would I achieve this?
Thanks, Tony

1 comment
You need to update the variable chosen when you run the function, so it isn't always equal to false, add chosen = true after button.TextTransparency = 0 and add chosen = false after button.TextTransparency = 1 so when the function runs the next time, it does the opposite