How To Create An Npc In Roblox Studio
Download Article
Download Article
This wikiHow teaches you how to create a basic shop in Roblox using a dialog script. Creating a dialog script is like writing a conversation between the merchant and the buyer.
Steps Download Article
-
1
Pick three weapons from "Weapons" in the toolbox. Your weapons appear in the "Workspace" branch in the explorer tree.
-
2
Drag the weapons into the "Replicated Storage" branch.
Advertisement
-
3
Rename the three weapons. To rename a weapon, right-click its name and type something unique (without spaces). Be descriptive!
-
4
Make an NPC. NPCs are commonly made from bricks, countertops, or boxes, although you are free to use whatever you wish. If you decide to use bricks, make sure you've anchored the bricks in place.
-
5
Select the three pieces of your NPC and rename them "NPC." To do this, drag the mouse to select all three pieces, right-click the selected area, and then click Group. Call the group "NPC."
-
6
Select the NPC's head from the right panel and click Head .
-
7
Insert a dialog. To do this, right-click Head and go to Insert > Object > dialog.
-
8
Change the "Purpose" property to "Shop." It's in the Properties section.
-
9
Type what you want your NPC to say. This goes into the
initialpromptbox.
-
10
Select the dialog in Explorer and go to Insert > Object .
-
11
Select DialogChoice and change the UserDialog property value. Change it to something like, "May I browse your goods?"
-
12
Add a response and dialog choices. Set the
ResponseDialogproperty to "Sure!" Then, insert three "DialogChoices" into the "DialogChoice" we just made. Rename them from their defaults and set their
UserDialogproperties to the names of the weapons.
-
13
Add a script into the dialog (not dialog choice). Now you can add the lua code for your script.[1] . It should read:
local dialog = script . Parent . 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 )
-
14
Save your game. Your store is now ready to use.
Advertisement
Add New Question
-
Question
How do I use the complicated code in Roblox Studio?
Copy and paste what is says above, However, make sure that you paste it in the right place our else it will not work.
-
Question
Does a shop have to have clothing?
BlobbieNado
Community Answer
No, your shop does not have to have clothing. Your shop can be whatever you want to! Just note, some users may want to see clothing and others may not.
-
Question
Were do you put the items?
You can always build your own items, or use the toolbar to find one you like and place them wherever you want in your shop.
-
Question
Do I need to be able to use scripts to make a game cool?
When you script in Roblox studios, it makes the game more interesting for your players. If you don't know how to script, you can find tutorials on youtube or you can search 'Roblox studio tutorials'.
-
Question
Can I buy my own items when I am playing for free?
gachaandrea_14
Community Answer
No. You can't buy your own items because it will show a message saying it's not for sale.
-
Question
But if the money is called "coins," should I change the script (for example: coins.Value = coins.Value - 10)?
Evan Leopard
Community Answer
Yes, whatever you currency is named should be changed in the script as well.
-
Question
I read the script, and what is the gold thing?
Evan Leopard
Community Answer
It is the currency inside of your game. So in this script the currency is called "gold" although it can be changed to whatever you desire (for example, coins, cash, dollars, etc.).
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement
-
Don't copy and paste the script. Writing it will make it function properly.
-
If you're having problems, be sure to check carefully for typos!
-
Make sure your names are exactly the same as the ones specified. Use the same capital letters and spaces.
-
You can add a GUI which shows your balance of 'gold'. YouTube has plenty of tutorials for those.
Advertisement
About This Article
Thanks to all authors for creating a page that has been read 41,289 times.
Did this article help you?
How To Create An Npc In Roblox Studio
Source: https://www.wikihow.com/Make-a-Shop-in-Roblox-Studio
Posted by: aldrichfater1942.blogspot.com
0 Response to "How To Create An Npc In Roblox Studio"
Post a Comment