Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-2

My GUI mover script is acting weird...?

Asked by 9 years ago

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)

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

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!

0
Just had to put the :connect function in there, and now it works! Stravellia 0 — 9y
Ad

Answer this question