Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you activate or deactivate textbuttons with scripts?

 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

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)

6 comments

0

I don't think i'm quite getting it yet. I've added the new code to my original post.

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!

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

0

oh, so it seemed you have the ClickEvent in different scripts.

0

You are using ServerScripts, you should use LocalScript instead!

0

I replaced the serverscript with a localscript, but it still doesn't seem to be working.

This discussion is preserved as it was. New answers, comments, and votes are closed.