Dialog Shop Tutorial
Introduction
In this tutorial we will learn how to make a Dialog Shop. This can be used in many things such as RPGs and adventure games.
These can also be used for different things other than just weapons, but today we're going to focus on weapons. Other things you can use in your shop: Driving Licenses, Exchanging Gold for XP and the list goes on.
But why a dialog shop?
Well, you can call it an upgrades shop. Like if you are making a dodgeball game, you could make one of these dialog shops to buy dodgeballs.
What you will need
- ROBLOX Studio
- To open or create a new place in ROBLOX Studio.
- Explorer
- Properties
Objectives
- To create a Dialog Shop.
- To have fun.
Putting the weapons in Lighting
Grab three weapons from the "Tools & Weapons" page in the Toolbox. In Explorer, you should see your three weapons under the Workspace directory. Drag and drop those weapons into Lighting.
Rename your weapons from "Weapon1" to "Weapon3"
Your hierarchy should look like this:
Workspace
Lighting
- Weapon1
- Weapon2
- Weapon3
The NPC
Now we need to make an NPC. Create a model containing Left Arm, Right Arm, Head, Torso, Right Leg, Left Leg.
The Dialog
Next, select the NPC's head. Go to Insert -> Object -> Dialog.
The Shop
In properties, change the Purpose property of Dialog to "Shop". Write in the InitialPrompt box what you want your NPC to say to you when you talk to him. I am changing mine to "Welcome to my shop!".
While your Dialog is still selected in Explorer, go to Insert -> Object -> DialogChoice. In the properties window, change the UserDialog property value to "May I browse your goods?" and the ResponseDialog property to "Sure!".
Insert three DialogChoices into the DialogChoice we just made. So your hierarchy should now look like this:
Rename them from "ChoiceA" to "ChoiceC" and set their UserDialog property to the names of the weapons.
Workspace
- NPC
- Head
- Dialog
- DialogChoice
- ChoiceA
- ChoiceB
- ChoiceC
- DialogChoice
- Dialog
- Head
Lighting
- Weapon1
- Weapon2
- Weapon3
Insert a script into the Dialog found in the Head of your NPC. Make the script's source as followed:
script.Parent.DialogChoiceSelected:connect(function(player, dialog)
if dialog == script.Parent.DialogChoice.ChoiceA then
if player.leaderstats.Gold.Value >= 5 then -- 5 is the amount of gold you need to purchase this weapon
game.Lighting.Weapon1:Clone().Parent = player.Backpack
end
elseif dialog == script.Parent.DialogChoice.ChoiceB then
if player.leaderstats.Gold.Value >= 10 then
game.Lighting.Weapon2:Clone().Parent = player.Backpack
end
elseif dialog == script.Parent.DialogChoice.ChoiceC then
if player.leaderstats.Gold.Value >= 15 then
game.Lighting.Weapon3:Clone().Parent = player.Backpack
end
end
end)
That's all we need to do! Here's your hierarchy, I hope:
Workspace
- NPC
- Head
- Dialog
- Script
- DialogChoice
- ChoiceA
- ChoiceB
- ChoiceC
- Dialog
- Head
Lighting
- Weapon1
- Weapon2
- Weapon3