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

Cars Spawning from within Each Other, How to Put Distance in Between Them?

Asked by 7 years ago

I am trying to spawn cars based on the number of players in a racing game. However, it seems to be that depending on the number of players -- those cars spawn within each other, therefore, glitching. Because of this, you can't drive them either. The car model is in ServerStorage and being called from there. But since models do not have a .Position property they can't be separated with that property. What can I do in order to put distance/separate in between the cars, so they can be drive-able?

This is the code:

function createCars()
    for _, object in pairs(game.ServerStorage:GetChildren()) do
        local carCopy = game.ServerStorage.Car:Clone()
        carCopy.Parent = game.Workspace
        carCopy:MakeJoints()
    end
end

for i = 1, game.Players.NumPlayers do
    createCars()
end

1 answer

Log in to vote
1
Answered by 7 years ago

You can move models with the :MoveTo() function

carCopy:MoveTo(Vector3.new(0, 10, 0))
Ad

Answer this question