Script not working as intended

So im creating a game and i wrote this script for a shop GUI to come up when i press the button for it


all of the things are referenced correctly but its not working, there are not errors in the console or the output
i decided to go on and make it on another one, but the same thing happened please help me

2 Likes

you’re doing game.StarterGui instead of game.Players.LocalPlayer.PlayerGui

game.StarterGui and game.Players.LocalPlayer.PlayerGui are completely different things. alternatively, you could also just do script.Parent

2 Likes

Use a localscript instead, and do something like:

local player = game.Players.LocalPlayer
local coinGUI = player.PlayerGui.ScreenGui.ShopBackground.CoinsGUI
local coinButton = (directory of coin GUI here, starts with player.PlayerGui)

coinButton.MouseButton1Click:Connect(function()
CoinGUI.Visible = true
end)

The reason of your method not working is because you must find the PlayerGui instead of StarterGui.
That’s why I suggested you to use a localscript if possible. Tell me if this works or not

2 Likes