Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I go about making this coffee machine I have in mind? [closed]

Asked by
SuperFryX 130
8 years ago

(Edit: Please read all the way through, this isn't a script request, I just want to know how I should plan the script in hopes of learning how to script more efficiently)

I'm planning on building an Coffee maker. Basically, I want to make it so it brings up a GUI in which you select what type of coffee you want and the flavorings you want for it, then you press enter and an empty coffee cup will go on a conveyor belt into which it will make 2 stops, 1 to get the coffee poured in, and the second to get the flavorings on, and after that it will become a tool.

I can probably do this on my own, but I want to improve the efficiency of my scripts as they are pretty messy. So how would I go about organizing it and such? I've never used tables really and I think this might be a great time to practice with those too.

Basically, I just need you to tell me how the basic layout of this script should go.

Closed as Not Constructive by UserOnly20Characters, docrobloxman52, and YellowoTide

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
2
Answered by 8 years ago

Well, to start, you should use SurfaceGuis for the button to trigger the coffee GUI. You can make a part, then insert a SurfaceGui into there, and insert a frame into the SurfaceGui, then do your button design there.

Now, you want to set up a click handler for the button (I'll let you figure that out), that shows the coffee GUI. Design the GUI, then add click handlers to the buttons to do the following:

  • Set the type of coffee you want (just store it in a variable in the script, change it for the different buttons)
  • Get the flavorings that you want (again, store it as a variable)

Then, you'll need a coffee cup model. Get one and store it in ReplicatedStorage, then do this:

local cup = game.ReplicatedStorage.TheNameOfTheCupModelHere:Clone()
cup.Parent = game.Workspace.WhereEverTheConveyorBeltIsStored -- I'm not sure if that'll work. You may need to change this...

-- Calculate where to move the cup for the first stop
-- When that's done,  move the cup to the calculated position, then do whatever you need to do to "pour" the coffee
-- Then calculate where to move the cup for the second stop
-- When THAT's done, move the cup to that position and put the flavorings in it

-- Remember, you have to have models of some sort for the actual coffee/flavorings. Otherwise it won't work properly. There is a way to make them small enough to fit, but it may get a bit difficult.

-- Now, move the cup a final time somewhere, then when that's done, set the Parent of the model to the player's backpack...
cup.Parent = game.Players.LocalPlayer.Backpack

Note: I didn't test most of the stuff, so it probably won't work as expected. Hopefully I helped, though!

0
You can also use ClickDetectors, they're good too! UltraUnitMode 419 — 8y
Ad