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?
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).
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
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!
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.
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!
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.