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

How do you activate or deactivate textbuttons with scripts?

Asked by 5 years ago
Edited 5 years ago
 local textButton = script.Parent



repeat

wait(2)

if script.parent.parent.AspectSelection.Text == '' then

if script.parent.parent.ClassSelection.Text == '' then

script.parent.Text = 'Please select a class and aspect'

else

script.parent.Text = 'Please select an aspect'

end

elseif script.parent.parent.ClassSelection.Text == '' then

script.parent.Text = 'Please select a class'

else

script.parent.Text = '>Enter'

textButton.Active = true

end

until 1 == 0



script.Parent.MouseButton1Click:connect(function()

script.Parent.Parent.Enabled = false

end)

I'm trying to make a button that stays inactive until you meet certain requirements (clicking two other buttons essentially). I've managed to get it to detect whether or not the requirements have been fulfilled, but i can't get it to actually reactivate the button.

Altered code based on NickAtNick's response

    local textButton = script.Parent

local bool = true

repeat



wait(2)



if script.parent.parent.AspectSelection.Text == '' then

if script.parent.parent.ClassSelection.Text == '' then

script.parent.Text = 'Please select a class and aspect'

script.Parent.Activated:Connect(function()

bool = not bool -- toggle

end)

else

script.parent.Text = 'Please select an aspect'

script.Parent.Activated:Connect(function()

bool = not bool -- toggle

end)

end



elseif script.parent.parent.ClassSelection.Text == '' then

script.parent.Text = 'Please select a class'

script.Parent.Activated:Connect(function()

bool = not bool -- toggle

end)



else

script.Parent.Activated:Connect(function()

bool = bool -- toggle

end)

script.parent.Text = '>Enter'

end



until 1 == 0





script.Parent.MouseButton1Click:connect(function()



script.Parent.Parent.Enabled = false



end)



script.Parent.MouseButton1Click:connect(function()

script.Parent.Parent.Enabled = false

end)

Requested screenshots

1 answer

Log in to vote
0
Answered by 5 years ago
Edited by User#24403 5 years ago

With a boolean variable local bool = true, true is when the button is activated and set the boolean variable to false to deactivate the textbutton! First , store a boolean variable with the var. Name of your choice then set it to true

 local textButton = script.Parent
 local bool = true -- it can be false...

Next, just "invert" the value with the not logical operator:

script.Parent.Activated:Connect(function()
    bool = not bool -- toggle
    -- other stuff
end)
0
I don't think i'm quite getting it yet. I've added the new code to my original post. timausTestified 2 — 5y
0
seemed someone edited my answer.... but can you actually make a gif or an album of what u are really trying to do?? or screenshot your startergui in explorer! thanks if possible! NickAtNick 163 — 5y
0
I've added a link to an album with both a screenshot of explorer and some screenshots of the actual ui illustrating what i'm trying to do timausTestified 2 — 5y
0
oh, so it seemed you have the ClickEvent in different scripts. NickAtNick 163 — 5y
View all comments (2 more)
0
You are using ServerScripts, you should use LocalScript instead! NickAtNick 163 — 5y
0
I replaced the serverscript with a localscript, but it still doesn't seem to be working. timausTestified 2 — 5y
Ad

Answer this question