Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My GUI mover script is acting weird...?

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

✓ Accepted answer

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!

1 comment

0

Just had to put the :connect function in there, and now it works!

This discussion is preserved as it was. New answers, comments, and votes are closed.