Screen GUI & Frame won't become Visible when using Script

INTRODUCTION

I’m trying to make this GUI Show up using a Script and trying to make a Frame Visible when clicked by a button, in its properties it has ScreenGUI Enabled Checked, and Frame Visible Checked but it dosnt actually show it being Visible in the Client, What Am I Doing Wrong?

Showing Screen Gui Script (Tried using Local & Normal Script) (None of them Showed the GUI)

local Button = script.Parent
local Shop = game.StarterGui.MainShop
local Enabled = false

Button.MouseButton1Click:Connect(function()
	if Enabled == true then
		Shop.Enabled = false
		Enabled = false
	else
		Shop.Enabled = true
		Enabled = true
	end
end)

Opening Frame Script (Tried with Local Script) (Dosn’t Show Anything)

local MainGUI = game.StarterGui.MainShop
local Item = script.Parent
local Price = script.Parent.Price
local OwnedCheck = script.Parent.Owned

Item.MouseButton1Click:Connect(function()
	if OwnedCheck == true then
		MainGUI.OwnedItemFrame.Visible = true
		MainGUI.OwnedItemFrame.Description = Item.Description.Value
		MainGUI.OwnedItemFrame.Price.Text = Item.Price.Value
	else
		MainGUI.BuyItemFrame.Visible = true
		MainGUI.BuyItemFrame.Description.Text = Item.Description.Value
		MainGUI.BuyItemFrame.Price.Text = Item.Price.Value
	end
end)
1 Like

Ah yes, the StarterGui

Just reference the Shop using Button.Parent.Parent (Or wherever your GuiObject is), cause the StarterGui Service is only on the server-side that eventually replicates to clients whenever they join

3 Likes

Dang I forgot about that sorry.
I was just trying new styles of scripting & learning more stuff i totally forgot about that.
thanks tho. no way ill get used to scripting if i cant remember that.

As @JackscarIitt mentions, you aren’t supposed to change startergui, that doesn’t effect the player itself, startergui is what holds gui for replication when player respawns or joins in.

Another way you could approach it, is by referencing the LocalPlayer & Player’s Gui instead (Since that’s handled on your individual client)

Keeping in mind that the StarterGui & PlayerGui are 2 different things, & handling client-related things should be in a LocalScript:

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local MainGUI = PlayerGui:WaitForChild("MainShop")

local Item = script.Parent
local Price = script.Parent.Price
local OwnedCheck = script.Parent.Owned

Item.MouseButton1Click:Connect(function()
	if OwnedCheck == true then
		MainGUI.OwnedItemFrame.Visible = true
		MainGUI.OwnedItemFrame.Description = Item.Description.Value
		MainGUI.OwnedItemFrame.Price.Text = Item.Price.Value
	else
		MainGUI.BuyItemFrame.Visible = true
		MainGUI.BuyItemFrame.Description.Text = Item.Description.Value
		MainGUI.BuyItemFrame.Price.Text = Item.Price.Value
	end
end)

it works now tho. im currently working on a Animation shop to buy and equip animations
this helped out alot. thanks.