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

I dont know why, but i want to make an open close GUI and it doesnt work why?

In the open Button Localscript is:

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Visible = false
	game.StarterGui.ScreenGui.Frame.Visible = true
end)

And in the close Button Localscript is:

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Parent.Visible = false
	game.StarterGui.ScreenGui.TextButton.Visible = true
end)

It needs to be an error even my scripter friend says that it should work Please help!

1 answer

Problem

StarterGui is a container for your GUIs. When a player joins the game, the contents of StarterGui will be replicated and placed in the player's PlayerGui.

Solution

Reference the GuiObject from PlayerGui

FIXED CODE

local Client = game.Players.LocalPlayer
local PlayerGui = Client.PlayerGui


script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Visible = false
    PlayerGui.ScreenGui.Frame.Visible = true
end)


script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Parent.Parent.Visible = false
    PlayerGui.ScreenGui.TextButton.Visible = true
end)

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