I want to make 2 buttons inside of my shop GUI so that I can toggle between the coins shop and the robux shop.
The problem is that the Robux or coin shops will not show up when I playtest.
I have tried playing around with the code but I am new to scripting.
We don’t really have a sample code to work with here.
Hey @pixi021,
There are some things that it is important to be considered to confirm and understand:
- How does the Graphical User Interface looks like in your game to understand the UX?
- Is there any chance for you to provide the code?
2.1 Mind if you tell us where is the script stored at?
Thank you!
Hey, thanks for replying
I made 2 scripts that are the same but for the different scrolling frames.
here is the script:
script.Parent.MouseButton1Click:Connect(function()
if script.Parent.Parent.Shop.Visible == false then
script.Parent.Parent.Shop.Visible = true
else
script.Parent.Parent.Shop.Visible = false
end
end)
the script is a local script and the GUI looks like this:
The 2 buttons at the top are for toggling through the different GUI shops
Thanks,
Oh my fault that isnt the script sorry i got the wrong one its actually:
if game.StarterGui.GUI.Shop.CoinsButton.MouseButton1Click then
game.StarterGui.GUI.Shop.CoinsScroll.Visible = true
else
game.StarterGui.GUI.Shop.CoinsScroll.Visible = false
end
It shouldn’t be StarterGui as it is only a folder that will clone the children inside and parent it to the player when a player (re)spawns. The Gui for players is inside of PlayerGui which is inside of player so your code should look something like :
game.Players.PlayerName.PlayerGui.GUI.Shop.CoinsScroll.Visible = not game.Players.PlayerName.PlayerGui.GUI.Shop.CoinsScroll.Visible
I simplified the script and make sure to chnage PlayerName
to the player name you want to make the frame invinsible or visible. But also I would highly recommend handling player GUI from the client side.
For more info about StarterGui : [Roblox Documentation - StarterGui](https://create.roblox.com/docs/reference/engine/classes/StarterGui)
I don’t understand what you mean with the PlayerName and handling GUI from the client.
Alright, If you are talking to me please reply to my post since I can’t recieve notifications otherwise.
Some stuffs I want to ask :
- Do you know what a client is?
- Do you know the diffrences between a localScript and a Script?
If you do know these then, let’s answer your questions.
-
PlayerName is the player’s name or better known as Username of a player who is playing in your game. For example Pixi021 is a player name (Username)! When a playr joins your game Some of their properties are stored inside of “Players” with their userName. Basically in a form of a table! When you play in Roblox Studio, Why don’t you open the explorer tab and see all the stuffs inside of the “Players” folder? You might see your userName or “Player1” if you are testing in another server! and inside of these UserNames you might see more stuffs!
-
Handling / Mangaing Gui from the client is basically just writing code for Gui with a localScript! I mean doing it from a script is just gonna tell the server the changes when you don’t need to! After all only that certain player is going to see the gui. This will also cause unwanted lag / reduced frames.
I’d recommend you watching tutorials, reading the roblox docuentation and read problems in DevForum if you want to improve.
put the code below instead of this one you’ll see something but it will only change for you and only if you are in the server else it will return an error (it’s in a script)
game.Players.pixi021.PlayerGui.GUI.Shop.CoinsButton.MouseButton1Click:Connect(function()
game.Players. pixi021.PlayerGui.GUI.Shop.CoinsScroll.Visible = not game.Players. pixi021.PlayerGui.GUI.Shop.CoinsScroll.Visible
end)
If you’re creating the UI objects by using the Instance.new()
property you’ll need to parent it to the PlayerGui. You can connect the PlayerGui by finding the player in your local script, like this:
local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild(“PlayerGui”)
-- // Create the UI Element and parent it to the PlayerGui variable
UIElement.Parent = PlayerGui
I mainly get the difference between a local script and a script but I’m not sure about a client
the script you provided works but only for me as a player, how do I change that so it works for anyone who joins like parenting it to their player name?
In Roblox, the Client side handles graphics and user input on your device, while the Server side maintains the game state and ensures synchronization among all players.
Furthermore, if you want to understand this difference in terms of networking, I remember having an advice message from the user “@DylWithlt” about it and he explained it on a technical/basic level:
What is a Client? What is a Server?
Starting from the very basics let’s start with some general definitions.Server
A server is a machine that takes and processes requests and provides resources to other computers that are connected to it. A single server can service multiple other computers at once.In the context of Roblox a server is a VERY small piece of Roblox’s network they set aside in order to host your game or any game you connect to. It may help to think of it as: Server = Roblox Computer
Client
A client is a machine that is connected to a server. Client’s can also send and receive requests, however they are often not the “authority” on any information and mostly serve to make requests to the server and get updates from the server.Clients in Roblox are the players. When you press Play on a game your game “Client” will start up and Roblox will try to connect you to a specific server for you to play on. If one is already there it will connect to that, if none are open it will try to start a new server for you to play on.
Anyways, from what I understood, you want to make the UI (User Interface) buttons switch from one scrolling frame to another, correct, @pixi021? If so, I decided to make a GUI (Graphical User Interface), containing more properties and to ensure that it cannot be changed by any user (for any security purposes).
You can edit the place and check out how it was built:
Let me know if that helps you out!
For this you will need to handle/manage your Gui from a local script so the script i’ll give can work :
local Gui = script.Parent --// define the path
Gui.Shop.CoinsButton.MouseButton1Click:Connect(function() --// call a function whenever the button is pressed
Gui.Shop.CoinsScroll.Visible = not Gui.Shop.CoinsScroll.Visible --// sets the visibility to false if it's true or to true if it is false
end)
For this to work your local script must be inside of GUI. Again, There are so many tutorials on youtube as well as DevForum - Community Tutorials I’d recommend you checkng those and reading Roblox Documentation - Scripting Guides to get a better understanding of stuffs, And It’s really helpful.
Thanks so much!
I’m pretty sure I understand Clients and Servers now that you defined that and that place you provided is very helpful I learned a lot messing around with that but it’s so complicated for me, though I’m almost certain now that my game functions as intended.
Thank you,
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.