So, I am trying to make a script for a click button that, when clicked, moves a GUI from Lighting to StarterGui. When I test it, no errors pop up in the Console, and the GUI does move to StarterGui according to the Explorer, but it does not show up at all. When I check it in StarterGui, Visible is enabled and none of the transparencies are equal to 1, but it will not show up.
function onClicked() if game.Lighting.TermCap.Parent ~= nil then game.Lighting.TermCap.Parent = game.StarterGui wait(.1) game.StarterGui.TermCap.Frame.Visible = true else end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
The stuff in the StarterGui isn't visible to the player.
Every time a player spawns, everything in the StarterGui is copied to that player's personal PlayerGui.
You should move it there, instead:
function onClicked( playerWhoClicked ) game.Lighting.TermCap:Clone().Parent = playerWhoClicked.PlayerGui end
You should be moving a copy (clone) instead of getting rid of it.
The check for game.Lighting.TermCap.Parent
was pointless -- it will always be game.Lighting
. If the object doesn't exist, you'll just get an error for asking for TermCap
in the first place (before ever asking for .Parent
)
You should keep things in ServerStorage or ReplicatedStorage. A GUI doesn't belong in the sky!