Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make a part generator?

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

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

7 comments

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?

0

I will modify my answer to account for that

0

thanks! I'm not exactly great with scripting yet :p

0

How do I move the part to the position of a ''PartSpawner''?

0

Sorry i'm a noob at scripting.. :c

0

That code is included there. The comments document the lines immediately above them

0

Which line is it? (sorry for wasted your time :p

This discussion is preserved as it was. New answers, comments, and votes are closed.