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

How to clone in a map and vehicles?

When the timer has dropped to 0, I would like the race to start.

All is well except I'm not sure how to clone in maps and vehicles. Also, when the vehicles are cloned in, how can I teleport each player to a separate boat?

Would like some guidance here.

2 answers

In order to clone objects and models, you have to use :Clone(). I'll try to walk you through on how to do this.

Step One, You should first put the object you want to later clone/copy in ServerStorage. That way it is safely hidden until you need to access it.

Step Two, You should now make a script. Make sure it's not a local script and that it is just a regular one. I recommend putting the script into ServerScriptService for script storage.

Step Three, The next obvious step would be to start coding! You First have to define some variables. Like so,

local Vehicle = game:GetService("ServerStorage"):WaitForChild("Car1")--Define The Vehicle. This Also Works With Maps.

You can add more but for the tutorial, I will just be cloning a car.

Step Four, It's now time to Clone the car. After Cloning it you Must make sure to define the car clone's Parent. Example,

local Vehicle = game:GetService("ServerStorage"):WaitForChild("Car1")

local CarClone = Vehicle:Clone()--Clones the car. The new cars variable name is "CarClone"
CarClone.Parent = game.Workspace

This here would make the car appear in workspace at the beginning of the game. But in order to make it not fall to pieces you Need to use MakeJoints(). Here's a link to more on How to make joints. But here's an example,

local Vehicle = game:GetService("ServerStorage"):WaitForChild("Car1")

local CarClone = Vehicle:Clone()
CarClone.Parent = game.Workspace
CarClone:MakeJoints()--Makes the car keep it's joints held in place.

You could also change the position of the Cloned Object or Model but it's not technically necessary. If However, you would like me to explain this, let me know. (:

Now that Should work. Good luck!

3 comments

0

Of course you could just put this code in "After" your timer if you wanted that xD.

0

But how would I get players to spawn on separate vehicles? Wouldn't they just pile up on the same one?

0

I didn't read you question very well xD

Scripting Helpers Is NOT a request site.

Well there are currently two ways that I know how to do this. My favorite way is using the :Clone() method. If you use it I would suggest having the thing you are cloning in Server Storage.

Example Below

x = game.ServerStorage.NameOfObject
n = x:Clone()
n.Parent = game.Workspace

And the next way I know how to do this is well, simply Moving the object to and from the place you want it.

Alright so basically its a lot simpler to use but could cause some minor lag. Example Below

x = game.ServerStorage.NameOfObject
x.Parent = game.Workspace
wait(race_time + 1)
x.Parent = game.ServerStorage

Hope this helps.

2 comments

0

You added nothing on to my initial answer. You could help by explaining how to teleport the players. Like he asked for in his question.

0

I wasn't adding on to your initial answer, I showed him to different ways to clone in(or just move an object) to the map, I myself don't genuinely know how to do the other portion.

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