Hello. I’m trying to make an infinite road, but I don’t just want to clone it over and over. I want to clone it until it gets to the horizon, then when it moves back (the road moves, not the car. it’s an illusion) I want to delete the part at the back and add a new one at the front. Here’s the code that I have now.
local road = workspace.Roads.Road
local rs = game:GetService("RunService")
local driving = true
road:SetPrimaryPartCFrame(road.Hitbox.CFrame + Vector3.new(0,0,0.5))
I don’t really see a situation where this is the best solution. For any kind of illusion to work you’d have to also move the scenery surrounding the vehicle - and even then I would expect some stutter. If you are set on doing this, however, I think the best way to do it would be to have the road between horizons split into multiple parts. A few parts would be within the field of view and the others would be outside. The connected parts could then tween forwards with the foremost parts being deleted when they pass the horizon/field of view and a clone being added to the back of the road. You could probably also weld the whole structure to a single piece which is also destroyed/remade when it reaches the end. This would allow you to only repetitively tween a single part.
If you really just wanted an illusion you could probably get away with making a large circular road with scenery which you tween around a fixed position.
The rotation idea just requires a basic idea of Tween . You would just have to weld a map/road to a central part which you repetitively tween 360 degrees.
I wrote a basic script for the other idea. It’s not well optimised but it works and the logic is what matters here. The colour changes are purely cosmetic to show how it works better. I also made it so the road travels along the z axis, but that can easily be changed/edited.