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

How to make a part generator?

Asked by 9 years ago

So, I'm trying to make a factory in my game, and I want conveyor belts pumping out parts constantly. I already know how to make a conveyor belt, but I need to know how to create something that keeps producing the same part on certain intervals of time. If anyone could help, it would be greatly appreciated! -Future

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

To do something repeatedly, we use a form of loop. Since we want to do this indefinitely, a while loop is most appropriate.

while wait(10) do
    -- Every ten seconds, do the following:

    -- To make a brand new part:
    part = Instance.new("Part", workspace)
    -- Construct a new Part instance in the workspace
    -- Put the new object in the variable `part` so we can do stuff to it

    -- Or instead, to copy an existing part
    -- (only use this or the above, not both)
    part = game.ReplicatedStorage.FactoryObject:Clone()
    -- Make a Clone (exact copy) of a given object
    -- (may be in other places but I just picked
    -- ReplicatedStorage for this example)
    part.Parent = workspace
    -- Move that object into the workspace (otherwise it is invisible
    -- and essentially non-existent)

    part.Position = script.Parent.PartSpawner.Position
    -- Move the part to the position of a `PartSpawner` (example)
    -- For CSG objects, the above still works.

end
0
Oh my god BlueTaslem! I love your portal game, anyway, thanks for the answer, but I have more more question: I created a certain part using solid modeling I want to be looped, but how would I enter that specific part in the script? futurerobotblox20 0 — 9y
0
I will modify my answer to account for that BlueTaslem 18071 — 9y
0
thanks! I'm not exactly great with scripting yet :p futurerobotblox20 0 — 9y
0
How do I move the part to the position of a ''PartSpawner''? futurerobotblox20 0 — 9y
View all comments (3 more)
0
Sorry i'm a noob at scripting.. :c futurerobotblox20 0 — 9y
0
That code is included there. The comments document the lines immediately above them BlueTaslem 18071 — 9y
0
Which line is it? (sorry for wasted your time :p futurerobotblox20 0 — 9y
Ad

Answer this question