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

How do I make a Part Keep Respawning At a Certain Position?

Asked by 8 years ago

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?

1 answer

Log in to vote
0
Answered by
woodengop 1134 Moderation Voter
8 years ago

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
  • Vector3new link (Link)
  • Loops link (Link)
0
I already have the part, should I remove the Instance.new line? IBuildOn 15 — 8y
0
Yes, just define the part's location and place a clone method. `:clone()` woodengop 1134 — 8y
0
I am a beginner at this. Is it OK if you give me the full script, and explain what I have to fill in, please? IBuildOn 15 — 8y
0
Oh sure! woodengop 1134 — 8y
View all comments (8 more)
0
Thanks IBuildOn 15 — 8y
0
I'm confused what to put in "partToBegin", also, when I put the location: "local game.Workspace.Tycoon.Main.Creator1.Handle:clone()", the dot after "game", is underlined. IBuildOn 15 — 8y
0
Oh, and by the way, I already have a conveyor belt that destroys the part, I just wanted a script that respawned the part so it can keep destroying . IBuildOn 15 — 8y
0
partToBegin places your Part in a certain part's position, then I added 15 studs with it. You have your variable mistaken, should be `local part= --location`. woodengop 1134 — 8y
0
Oh Ok thank you IBuildOn 15 — 8y
0
One last thing, I see this is incorrect, what is wrong with it? part.Position = Vector3.new(18.312, 2.778, 49.123.Position)+Vector3.new(0,10,0) IBuildOn 15 — 8y
0
Remove the .Position woodengop 1134 — 8y
0
Oh thanks, but you didn't tell me about my other comment: "Oh, and by the way, I already have a conveyor belt that destroys the part, I just wanted a script that respawned the part so it can keep destroying ." IBuildOn 15 — 8y
Ad

Answer this question