I want to make a button that when pressed will not be visible ever again
you can put a local script inside of the button and put this in it
local button = script.Parent
button.MouseButton1Click:Connect(function() -- when clicked run below
button.Visible = false -- makes the button invisible
end)
Ok I know, I mean to make it disabled so when a joins and clicks it and then joins again it will still be invisible
You mean across game sessions? As in when it shuts down the server? If it’s within the same game session @Afraid4Life’s solution would still work.
Yes
you need to use datastores to see if they’ve clicked the button before: here’s a good tutorial
you could just do Destroy() instead of button.visible = false.
If I may ask, what is this used for? Wouldn’t it be easier to just set the visibility manually?
It is used for an rp game I made a character selection gui but I want them to only to have access to it once
If you never want this button visible again, simply destroy it:
<BUTTONNAME/LOCATION>:Destroy()
Keep in mind with the datastore, unless you have a mechanism to make it visible again, it would remain invisible forever (maybe not forever forever but you get the idea heh).
He wants it to remain invisible across game sessions.
The only ways to make something invisible is to make Visible
false or to destroy
it. You can also disable the ScreenGui by clicking the ScreenGui and making sure Enabled
is false.
So it will only destroy for the player right?
If you destroy it from the PlayerGui (local player folder called PlayerGui), yes.
Ok my other question is what if I left the server and joined another will it still be destroyed
No. From what I know, you rejoined which means everything will locally reset, meaning that the “button” will be visible for you again.
Ok so how do I make it not visible for me again?
If you destroy it, its gone. You can always store a backup in ReplicatedStorage and if you want it visible again, you can :Clone it from replicated storage and parent it to the PlayerGui. Another way is to just make Visible
false.
You need to set up a data store and have it set a value in the datastore if it was destroyed and check the key in future sessions if it was destroyed and re-destroy it if it was.