Text Button Not Turning Invisible When Needed

Good Day,

I am having some trouble with coding one of my Text Buttons. It is parented to the Text Button itself, under a Text Label, under a ScreenGUI under the StarterGui. I’m trying to get the button to appear after the play button for the game is clicked, and when clicked, the normal text button to dissappear. In the game, when the play button is pressed, it does appear. But when the normal Text button is clicked, it dissappears for a second and re-appears.

This is the code withing the button’s local script:

game:GetService("Players").PlayerAdded:Connect()

PlayButton = script.Parent.Parent.Parent.Parent.Menu.PlayButton
local ThiefThereButton = script.Parent

ThiefThereButton.Visible = false

while wait(.1) do

	if PlayButton.Visible ~= true then
		ThiefThereButton.Visible = true
		ThiefThereButton.Active = true
	end

	if script.Parent.MouseButton1Click:Connect(function(clicked)
		ThiefThereButton.Active = false
		ThiefThereButton.Visible = false
		end) then
	end
end

I’ve been trying to search for a solution but haven’t found one that works yet. Can someone please help?

Also if this post is in the wrong catergory or channel please let me know so that I may fix it.

What do you mean that it’s located under the Text Button?

You cant use this function in a if statement instead do this
also you dont have to set active false when you already set the visibility to false

PlayButton = script.Parent.Parent.Parent.Parent.Menu.PlayButton
local ThiefThereButton = script.Parent

PlayButton.MouseButton1Click:Connect(function()
    ThiefThereButton.Visible = true
end)

ThiefThereButton.MouseButton1Click:Connect(function()
    ThiefThereButton.Visible = false
end)

i dont know if this is what you’re looking for because I couldnt fully understand what you’re saying but let me know!

1 Like

Yes this did work.

This is now the updated script:

game:GetService("Players").PlayerAdded:Connect()

PlayButton = script.Parent.Parent.Parent.Parent.Menu.PlayButton
local ThiefThereButton = script.Parent

ThiefThereButton.Visible = false

PlayButton.MouseButton1Click:Connect(function()
	ThiefThereButton.Visible = true
end)

ThiefThereButton.MouseButton1Click:Connect(function()
	ThiefThereButton.Visible = false
end)

It makes this button appear after the play button is pressed. The when this button is pressed it now dissappears.
Thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.