What script should I use to make a part keep respawning in the position every certain time?
The reason I'm doing this is because I making a game where a part goes somewhere then disappears and I would like it to keep respawning. What script should I use?
This can be accomplished by using the Vector3.new
userdata, and a simple while
loop. First we need to define the part, i'll name mine Part
, easy. Next i'll define the position of Part
by using the Vector3
userdata that I was talking about, What is Vector3
? How do I use it? Vector3 is a group of three
values, 1st
is the x
value(width), 2nd
is the y
value(height), and last
is the z
value(depth), Now the while
loop, What does it do? The while
loop continues looping until theobject
defined is nil
or false
. Now lets set-up our script.
-- note this can be used with a script or a localscript. while wait() do -- always add a wait(), if not then, it will crash your studio. local part -- define location then include a clone method (OBJECTLOCATION:clone()) part.Position=Vector3.new(partToBegin.Position)+Vector3.new(0,10,0) -- partToBegin is the position the part will start at(so It doesn't spawn at the middle), vector uses studs. wait(TimeHere) -- place the time of destroy part:remove() -- this removes the object after the `wait` function is over. end