So I am trying to make a sword shop but I can work out how to make a script for a shop GUI to pop up and you can buy items for example: Hotdog, Sandwich, Burger and Fries.
I have tried most tips still searching so I thought why not ask the Dev Forum.
There are alot of threads with the same question, please search before creating a thread. I already have created threads on asking help to create shops.
To start out simple, if you want to have a NPC you click and make the gui pop up, you could insert a click detector in the NPC, then add a script.
script.Parent.ClickDetector.MouseClick:Connect(function()
game.StarterGui.ShopGUI.Enabled = true --Change ShopGUI to the name of the Gui
end)
Now customize the GUI how you want it to be (Make a frame, text, image buttons to buy things, and an exit button)
To script the exit button,
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Parent.Enabled = false -- Remember that your gui structure may not be the same as mine, so maybe add a parent, or delete one if it does not work.
end)
Isn’t it bad practice to use Server-Side Scripts to open UIs?
If yes, like every teacher in the world will tell you: “You will learn the mistakes and keep on doing them forever”. In short, that means that you shouldn’t give advice from bad code practices and instead teach the correct way, even if it’s a little bit more complicated.
It’s not just that but you shouldn’t be accessing StarterGui if your intention is to make any kind of interactable interfaces. StarterGui is only meant to be a container of Gui instances that will be given to the player upon respawning with exceptions as defined by the ResetOnSpawn property.
@OP There are many free shops on the catalog that you can reference if they just want a basic shop. This is something easily searched for and attempted. If you’re new to code, then it’s best you gain knowledge on the language and make an attempt yourself at doing this.