So I got a choice and you click one of two buttons. I will make them do stuff later on but for now I just want the GUI to destroy for good but when the player dies, it comes back. It's in a local script. I want it to show up when the player enters but once they click the button, it stays gone for that player forever.
local gui = script.Parent.Parent.Parent local function onClicked() gui:destroy() end script.Parent.MouseButton1Click:connect(onClicked)
Put this LOCAL SCRIPT inside of the gui...
local gui = script.Parent.Parent.Parent local function onClicked() Instance.new("ObjectValue", game.Players.LocalPlayer).Name = "NoGui" gui:Destroy() end script.Parent.MouseButton1Click:connect(onClicked) while wait(0) do if game.Players.LocalPlayer.NoGui then gui:destroy() end end
It will put an object value inside the player which will NEVER disappear even when they reset. This script doesn't affect everyone in the game only the player who clicked the gui. It's gone forever and no one can get it back.
This script will show the gui for a quick glimpse but It gets destroyed directly after.
local gui = script.Parent.Parent.Parent local function onClicked() gui.Visible = false end script.Parent.MouseButtton1Click:connect(onClicked)
Try using Remove
, but what you have should work...unless you are trying to remove it from ALL players then that script is a little more complicated. If you are trying to connect this to when your player dies, it needs to remove it from the local StarterPlayer
, other than that it will always come back if its in StarterPack
.