Train spawn script not spawning right

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    my train spawner script is not working
  2. What is the issue? Include screenshots / videos if possible!
    it does this
    problem.PNG

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

`e.new(-193.361, 128.26, 2159.586 + spawnedCars*89))
spawnedCAR.bogie.connector.BallSocketConstraint.Attachment1 = spawnedENGINE.bogie.connector:FindFirstChildWhichIsA(“Attachment”)
previouscar = spawnedCAR
print(randomCar)
else
spawnedCars+=1
tor:FindFirstChildWhichIsA(“Attachment”)
previouscar = spawnedCAR
end
end
end


Please do not ask people to write entire scripts or design entire systems for you. If you can't answer the three questions above, you should probably pick a different category.

Not saying it’s the cause of your issue, but you should really avoid using constants in your CFrame or position calculations unless you’re absolutely, 100% sure that CFrame will remain unchanged throughout the lifetime of the function. Even still, I would recommend keeping your CFrame calculations relative to the main car, the previous car, the track etc. Something that is a little more mobile that the static Vector3 position you have filled in.

In an attempt to give some sort of aid to your problem, try checking your joins and welds, it may be an issue with those or how you’re creating them in your script.

Instead of welds try using Motor6Ds, It’s much more better for making joints for moving objects (You can also animate it)

well I made it anchored when it spawns in because then it is hard to see that the cars are spawning in sideways. when it is unanchored the cars eventually get into the correct position but the cars start flinging around trying to get into their ballsocketconstraint since the cars are sideways. when the cars get into their correct positions the train is derailed. so I don’t think this is a problem with my constraints. I think the probelm is that I can’t figure out why the train cars are spawning in the wrong direction.