PDF download Download Article PDF download 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.

  1. Your weapons appear in the "Workspace" branch in the explorer tree.
  2. Advertisement
  3. To rename a weapon, right-click its name and type something unique (without spaces). Be descriptive!
  4. 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. 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. To do this, right-click Head and go to Insert > Object > dialog .
  7. It's in the Properties section.
  8. This goes into the initialprompt box.
  9. Change it to something like, "May I browse your goods?"
  10. Set the ResponseDialog property to "Sure!" Then, insert three "DialogChoices" into the "DialogChoice" we just made. Rename them from their defaults and set their UserDialog properties to the names of the weapons.
  11. 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 
     ) 
    
  12. Your store is now ready to use.
  13. Advertisement

Community Q&A

Search
Add New Question
  • Question
    The script isn't working, it says "unknown global dialog".
    Miłosz Szablak
    Community Answer
    Maybe you don't have enough of your currency or you don't have an leaderboard for your game.
  • 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.).
See more answers
Ask a Question
      Advertisement

      Tips

      Show More Tips
      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Name
      Please provide your name and last initial
      Thanks for submitting a tip for review!
      Advertisement

      About This Article

      Thanks to all authors for creating a page that has been read 68,937 times.

      Did this article help you?

      Advertisement