I was working a game which has more to come but I made it multi platformed gui so if you clicked on one of the options (pc, mobile) it would fit the gui to that screen (ui scaling) whenever you die or reset the gui pops up again. I tried to make it not pop up again with a local script with the following I set the gui enablility to false for the script
script.parent.Enabled = true if script.parent.Enabled == false then script:Destroy() end
It might not make sense to you because I put a local script when you clicked a button, what it would do is set the gui enability to false. by destroying the script the gui would not appear since its true enability is false and the local script is the only thing making it true
The script is not destroying itself because the script is only checking to see if the parent is enabled once. This being said, you have to develop something that continuously checks, or checks every time. If the condition is inside of a function or an event, then you should be fine. However, from what I can see it seems like you are only checking once.
In order to check continuously, you should use the following loop:
coroutine.resume(coroutine.create(function() script.Parent.Enabled = true while wait() do if not script.Parent.Enabled then script:remove() end end end))
If this is not what you were looking for please let me know, but I hope this helps!
script.parent.Enabled = true
if script.parent.Enabled == false then script.Parent:Destroy() end
Well depends how you want it to destroy. If you want to remove it permanently from the game you cant, because it will destroy in the client but it will stay into the other players. If you wanna remove it from the whole server you will need to use a server script for that probably.