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

My new Shop System in my game isn't working. Why is it happening?

I got a shop GUI for my new game and it dosen't work. This is how my explorer looks like

SHOPGUI> LocalScript Open> Frame> Buy> Close

game.StarterGui.ShopGUI.Open.Frame.Visible = false
local of = game.StarterGui.ScreenGui.Open
local cf = game.StarterGui.ShopGUI.Open.Frame.Close

of.MouseButton1Click:Connect(function()
	game.StarterGui.ShopGUI.LocalScript.Shop.Frame.Visible = true
end)

cf.MouseButton1Click:Connect(function()
	game.StarterGui.ShopGUI.LocalScript.Shop.Frame.Visible = false
end)

That is my script. Please do not change it completely but also show errors and common mistakes. Thanks!

6 comments

0

Is this a Server Script?

0

Nope

0

It is inside the GUI

0

What Gui?

0

SHOPGUI ! Have you read it?

0

Hey, can u read the comments of my answer?

1 answer

Its because you are using StarterGui, you need to use the gui which is inside of player, by calling Player:WaitForChild('PlayerGui'), because the StarterGui is the gui which will send to the client when the client joins in the game, but the PlayerGui, its currently gui of player.

Example:

local Player = game:GetService('Players').LocalPlayer
local PlayerGui = Player:WaitForChild('PlayerGui')

Then, just use this in your script, example:

local Player = game:GetService('Players').LocalPlayer
local PlayerGui = Player:WaitForChild('PlayerGui')
local ShopGUI = PlayerGui:WaitForChild('ShopGui') --/ Saving the gui in the variables.
local ScreenGui = PlayerGui:WaitForChild('ScreenGui')

ShopGUI.Open.Frame.Visible = false
local Open = ScreenGui.Open
local Close = ShopGUI.Open.Frame.Close

Open.MouseButton1Click:Connect(function()
    ShopGUI.LocalScript.Shop.Frame.Visible = true
end)

Close.MouseButton1Click:Connect(function()
    ShopGUI.LocalScript.Shop.Frame.Visible = false
end)

Hope it helped!

5 comments

0

It doesn't work

0

What the error?

0

It just doesn't work

0

The shop won't open or close and buy, you script has many errors I have also spotted

0

There shouldn't be anything wrong with this script, it has to be some information you're keeping from us

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