Dialog shops are easy to create and can be made to sell many different items, such as weapons, cars, or upgrades. They can also be used in a wide range of games from adventure games to RPGs. In this tutorial will be going over how to make a weapons shop.
As the shop is going to sell weapons, we will need to select at least one weapon to sell in the shop. There are some great weapons in the “Tools & Weapons” category of the Toolbox.
Now that we have a weapon we can get started. The weapon(s) should be located in the
Workspace, and we need put any weapons into
ReplicatedStorage. Rename the weapon to “Weapon1”, and if there is more than one weapon, name them like so: “Weapon1”, “Weapon2”, etc. At this point the
ReplicatedStorage should look something like this (if there is more than one weapon, it will look slightly different):
Making The Shop
In a shop there is always someone behind the counter ready to help you, and we now need to make this person. This seller can be as creative as you want her to be; for this tutorial, I will be using a basic
Part inside a
Model. We now need to insert a
Dialog into the seller, make sure that the part you insert it into is named “Head”. Next we will need to insert a
Humanoid into the
Model of the seller.
To insert a
Dialog go to Insert -> Object -> Dialog.
Now that we have the seller set up and ready to sell some weapons, we need to make the actual shop. To make the shop we will use
DialogChoice/ResponseDialog to ask questions and give answers.
To start, select the
Dialog that was created and in the properties window change the
Dialog/Purpose value to “Shop”. In the properties window again change the
Dialog/InitialPrompt value to whatever the shop keeper should say when the player interacts with her, I will be using “Welcome to my shop!”.
Next we will add the options the shopper can choose to ask the seller, we will do this by inserting a
DialogChoice into the
Dialog . To insert a
DialogChoice go to
Insert -> Object - > DialogChoice.
In the properties window change the
DialogChoice/UserDialog value to “May I browse your goods?” and the
DialogChoice/ResponseDialog value to “Sure!”.
Note: Any of the above text in quotations can be changed, it does not affect the shop.
Next we will need to Insert some more DialogChoices into the
DialogChoice we just made, insert as many DialogChoices as you do weapons. Rename them from “ChoiceA” to whatever amount of weapons you are selling, so if there were three weapons they would go from “ChoiceA” to “ChoiceC”.
The Dialog should now look something like this:
Make The Shop Do Stuff
To make the shop work we will need to insert a
Script into the
Dialog inside the seller’s head. Inside the script copy the following code:
Note: The code below uses a
local dialog = script.Parent dialog.DialogChoiceSelected:Connect(function(player, choice) -- Check the player has a stats object local stats = player:FindFirstChild('leaderstats') if not stats then return end -- And that the stats object contains a gold member local gold = stats:FindFirstChild('Gold') if not gold then return end if choice == script.Parent.DialogChoice.ChoiceA then if gold.Value >= 5 then -- 5 is the amount of gold you need to purchase this weapon game.ReplicatedStorage.Weapon1:Clone().Parent = player.Backpack gold.Value = gold.Value - 5 -- subtract the amount of gold you need to purchase end elseif choice == dialog.DialogChoice.ChoiceB then if gold.Value >= 10 then game.ReplicatedStorage.Weapon2:Clone().Parent = player.Backpack gold.Value = gold.Value - 10 end elseif choice == dialog.DialogChoice.ChoiceC then if gold.Value >= 15 then game.ReplicatedStorage.Weapon3:Clone().Parent = player.Backpack gold.Value = gold.Value - 15 end end end)