As you can see i am trying open the gamepass shop from the pluss button on the gems bar:
and sadly this code is so tricky that, I don’t know what to code.
As you can see i am trying open the gamepass shop from the pluss button on the gems bar:
Let me know if this doesn’t work, or if you don’t understand a part of the code!
local PlayerGUI = game.Players.LocalPlayer.PlayerGui
local shopGUI = PlayerGUI:WaitForChild("GamepassShopGui")
local button = script.Parent
shopGUI.Enabled = false -- by default shop shouldn't be visible
button.MouseButton1Up:Connect(function()
shopGUI.Enabled = not shopGUI.Enabled
-- toggles shop visibility to the opposite of what it was.
-- so if it was visible, it would become invisible and vice versa.
end)
By the way, I noticed that you are using ScreenGui objects instead of Frames, so I edited the code and made it so it changes the .Enabled
property instead of the .Visible
property.
Also, I do not recommend using different ScreenGuis for each GUI that you are making. It makes your game look messy, you should use frames in one ScreenGUI instead.
Use more ScreenGUIs only if you really need to!
ok thank you so much for helping, ill try it out now
its making the shop button disappear, then re-appear
Oh my bad!
local button = script.Parent
local shopGUI = button.Parent.Frame
shopGUI.Visible = false -- by default shop shouldn't be visible
button.MouseButton1Up:Connect(function()
shopGUI.Visible = not shopGUI.Visible
-- toggles shop visibility to the opposite of what it was.
-- so if it was visible, it would become invisible and vice versa.
end)
I changed the code so that the shopGui
variable was set to the frame that is your GamepassShopGui.
local button = script.Parent
local frame = script.Parent.ShopFrame
button.MouseButton1Click:connect(function()
if not frame.Visible then
frame.Visible = true
else
frame.Visible = false
end
omg omg omg thanks so much this is a big help!
though is there a way to make it just open?
If you want the button to only make the ShopGUI open, and not close. Then this should do it:
local button = script.Parent
local shopGUI = button.Parent.Frame
shopGUI.Visible = false -- by default shop shouldn't be visible
button.MouseButton1Up:Connect(function()
shopGUI.Visible = true
end)
kk ty thats all thank you for helping me a lot i’m quite new to coding (this is the first ever game im trying to make)
for some reason it wont work hmmmmmm
What is the error in the output window? Is the shopGUI
variable set to the right Frame?
Please provide with more details when things do not work, and not just “it no work pls help”.
It works in my test game, so there has to be something wrong with the GUIs probably. Or you changed the locations of the Frame.
Send a screenshot maybe
its not gone into the gamepassshopgui so its not opening the frame
Again, you’re not giving much information here. Just locate the frame in GamepassShopGui, and put it in the shopGUI
variable. You can do that, right?
Or just send a screenshot of the file explorer, and the script location so I can do it for you. Heres a video that might help you get a better understanding of how to reference things and change their properties. Or if you don’t wanna watch that there’s a post just for that
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.