I have finally finished the script (sorry for taking a while, I was taking a break). I will lead you through on how to set this up. Also you can change the length of the roads just make sure to change the new position vector.
Just make sure to make that number the same length in studs as your road.
local roadNumber = 1
local removedRoadNumber = -1
script.Parent.Touched:Connect(function(hit)
print(hit.Name)
if hit.Parent.Humanoid then
roadNumber += 1
removedRoadNumber += 1
local newRoad = script.Parent.Parent:Clone()
local oldRoad = game.Workspace[tostring(removedRoadNumber)]
newRoad:SetPrimaryPartCFrame(CFrame.new(newRoad.PrimaryPart.Position + Vector3.new(55, 0, 0)))
newRoad.Name = tostring(roadNumber)
newRoad.Parent = game.Workspace
oldRoad:Destroy()
script:Destroy()
end
end)
There’s the script and now here is how to set up the road parts.
In workspace there are models called 1 and 0, those are the roads (don’t worry about picnic table, that is something else)
I have only parts in the models but you can make it as intricate as you want. Don’t put any scripts in the road model “0”.
Just put the script under the part that the players will be walking on or the car that is touching.
Then finally you have to put them side to side like this:
I think you misunderstood me, the car isn’t moving. I just want the road to move to make it LOOK like the car is moving. Also, the car would be touching the road, not the player.
Sorry I am just confused on what you want. I made an infinite road and you want them to stand on the car? I want to find solutions, I am sorry if I am asking to many questions. I just want to get it right.
The car is not moving, the players are on the car. The road is moving backwards to give it the illusion that the car is moving. I want the road to clone itself and delete the ones the car has already passed.
local TweenService = game:GetService("TweenService")
local road = script.Parent.Parent
local roadRoot = road.PrimaryPart
local moveInfo = TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local moveTween = TweenService:Create(roadRoot, moveInfo, {CFrame = roadRoot.CFrame + Vector3.new(200, 0, 0)})
local function resetRoad()
moveTween:Play()
moveTween.Completed:Wait()
road:SetPrimaryPartCFrame(CFrame.new(roadRoot.Position - Vector3.new(200, 0, 0)))
end
while wait() do
resetRoad()
end
That is the script I came up with so that the car is not moving but the road is. I suggest making the road longer and add fog so that they can’t see it teleporting. Same thing as last time, you have to replace the Vector3 values with the length of your road.
Also I have a welding script so that you can attach any extra parts to the main road if you need that.
I just recommend something easier, take a beam, make a road texture using paint or GIMP. Then apply that texture to the beam. Set its texture speed to 2 by typing it in. Then you have a moving road that doesn’t actually move, it will save lag.
nothing to do with your discussion but actually I’m really struggling with a script that should make an entire model move infinitely in a certain direction and so … if you’re willing to help me with that, I will be really grateful to you (I mean…its kinda related to that message at least).
If you move an entire model too far from Position 0,0,0 then you start to get something called floating point error.
Since computers calculate values with a base 8 setup, trying to convert that to a base 10 number (decimals) results in very tiny decimal errors (like 0.0001 studs) but if you multiply that by something like 10000 studs from center you’d get a 1 stud difference in each Part’s Position. It wouldn’t be the same as the error in all the other Model’s Parts so all those Parts start to move around in relationship to each other.
If your player is going to be with the model it won’t work. Players are multiple Parts.
Also any movement of the model would be erratic since it’s Position would be jumping around.