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

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

Asked by 2 years ago

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

Log in to vote
0
Answered by 2 years ago

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)
Ad

Answer this question