How to make a system like this:

Heyo, how can I do something like this:

https://gyazo.com/72231e29a714d2c2239b4ec36342289e

I want to make it so a npc walks up to the players, makes a order, and then if the order is correct they get points. I know it’s alot, but can someone help me?

3 Likes

There are various resources you can look around for in order to assemble a system like this. Define your requirements and set out searching for what you need. “Can someone help me” is too vague a question for this category. Help you do what?

A lot of what you’ll require for this system can be uncovered by looking around at it a bit. Dissect it and apply code as you need to fit the requirements. It should all eventually fall into the greater system (e.g. when an order is placed, the selection Gui activates and defines what the order is made of, which the player needs to match via their Gui).

1 Like

You can’t ask help when you are not telling us what we can help you on, if you are asking the whole script then we can’t help you maybe.

This category is to help people on scripting bugs, a question of something or anything that you want to add on the script that you are making.

We can help you on create something but not create the whole script.

well, @Conejin_Alt im just looking for how the npc could place the order, and make it randomized. I just need help on that.

With place the order what do you mean?

About making it randomized you can set a script and write something like this code:

local RandomThing = math.random(1,6) --6 Are the orders

if RandomThing == 1 then --If the order is the number one then
print("NPC has ordered pizza")
elseif RandomThing == 2 then --If the order is the number one then
print("NPC has ordered hamburger")
end

You can set more numbers as you please. I hope this helped you a bit :+1:

1 Like

Or you could put this into a table.

local Order = {
[1] = {Food = "Burger", Side = "Fries", Drink = "Cola"},
[2] = ect.
}
local ChosenOrder = math.random(1,#Order)

Then use ChosenOrder in the appropriate way with the food selection surface gui.

I’m not that good at explaining, lol, basically by ordering, the npc has a chat bubble like shows in the god, and in the bubble it shows the order.

And thanks, this helped!

The whole system is a mixture of different things I recommend learning each individually with a quick search.

2 Likes

You can make an instance of a BillboardGui in the script where selects the order, after the lines i wrote you write this:

local NPC = game.Workspace:FindFirstChild("NPC")
local Chat = Instance.new("BillboardGui", NPC.Head)
local Text = Instance.new("TextLabel",Chat)

I’m not good using billboards but i will let you learn that for yourself, and now you must write this:

Text.Text = "I wan't a "..ChoosenOrder.." please!"
wait(5)
Chat:Destroy()
1 Like

I think I should mention that you wont get very far by just following us here, you must do your research elsewhere whilst working on an entire system as there are lots of parts. Use our code as a guide and goodluck!

1 Like

I must mention this again that this category is made for helping on scripting but not making the entire script, that’s why im not testing it, i want to him gets the errors and mistakes so later he can solve them by himself or asking a bit of help, giving the entire script to him may cause that he never learn what we gave him and have the bad habit to ask scripts always.

1 Like

Maybe try using this video.

5 Likes

Oh, I feel dumb, I searched; working system and I couldn’t find that! Thank you so mych!

1 Like

Just a side note, never ever use the parent argument in the constructor function Instance.new. It has a massive performance problem, if you want more info then check this out.. Asides, moving back onto Scythes post, making a table is a good idea. You could do something with tables for maximum randomability is that a word? using table.getn() and math.random rather than making tables with set sides, drinks and mains.

Other than the code base, the UI part is easier. Just make assigned icons to their respective food items, probably a table… I’m not sure how you would communicate the meals, maybe via values to be honest communicating via values is something but it is pretty long winded, I just cannot think of alternatives on the spot right now

Uh oh, submitted a little to late. Well done on finding a solution though!

1 Like

I read a while back about the parent argument having a small performance problem so I have always parented it manually in my work, however I did expect this issue to be fixed by now. Is there a reason it can’t be?

What do you mean when you refer to issue being fixed, use of the parent argument? That’s never been an issue. The fact of the matter is that once you attach the instance to the DataModel, it gets hooked up onto a bunch of processes and signals start activating so overall you’re introducing more overhead when setting properties after the instance has been attached to the DataModel.

Setting properties first before the parent allows the object to be attached with its predefined necessities. Read the post again and more carefully, everything is explained there.

Well I mean in general for future developers who don’t know of the performance decrease why dont they give some sort of warning.

Edit: Sorry for any confusion I was in a bit of a rush :sweat_smile::+1:

There is, unless you’re one of those people who doesn’t read documentation or search first.

1 Like

Looks like I am incapable of reading :man_facepalming:

Thank you again colbert I do appreciate your help on the forum.