Hey guys. I have this script here that successfully clones the variable "Tracks" and puts it directly in front of the previous tracks. I was wondering if its possible to use math to add 24 to X position (i figured out the size between the tracks) that would put it directly in front of the cloned one, so when a train crosses over the part that has the ontouched script it, it will clone the tracks again and again, so in theory will go forever.
function hit (track) local part = game.Workspace.Tracks local cloned = part:Clone() cloned.Parent = game.Workspace cloned.Position = Vector3.new(-39, 5, -34) end script.Parent.Touched:Connect(hit)
if this explanation is hard to read please tell me. Thanks!
You can add vectors together using math.
This should produce the result you are looking for:
NewTrack.Position = OldTrack.Position + Vector3.new(24,0,0)
This works because Position is a Vector3 value. It can be manipulated with math operators (+, -, *, /) in comparison to another Vector3 value.
In effect, the equation above is equal to: NewVector = ((X1 + X2), (Y1 + Y2), (Z1 + Z2))