[SOLVED] Help on infinite road

This problem has been solved but feel free to still look at this. This chat has ended so no more comments will be replied by me

FYI

This is my first Topic post so if something looks wrong please let me know thanks :grinning:

Hello! I am trying to make an infinite road that moves and never stops that makes somewhat of a cut scene. If you ever played Bus Simulator you will know what I mean

Link to game

https://www.roblox.com/games/2091563160/Bus-Simulator

I’m trying to make it so that way if the code fails the output will be messaged. This is what I have so far (This is in my test server)

Capture Note that behind Model4 is the workspace

From top to bottom of my scripts I have this

Script 1
wait(3)
while true do --you will see why it repeats in a few lines later
	local gwm4 = game.Workspace.Model4 --easier if i just do that
	gwm4.InfiniteRoad.Script.Disabled = false --make disabled script enabled
	
	if gwm4.InfiniteRoad.Script.Disabled = false then -- double checking I think here is the problem
		print("Infinite Road script loaded successfully")
		script:Destroy() --the script worked and is not needed anymore so it will be deleted
	elseif
		print("error retrying") --this is where the while true do comes in
	end
end

This one was from the toolbox but i changed it to go somewhat of how I want it this is not the final version of this next script because I need to do testing

Script 2 (disabled)
time = 0.5 --Time between movements

brick = script.Parent --So you don't have to rename anything

-----------------------------------------

moveX = 0

moveY = 0 -- Moves X up by one.

moveZ = 4

-----------------------------------------

while true do -- Makes a loop

brick.CFrame = brick.CFrame + Vector3.new (moveX, moveY, moveZ)

wait (time)

end -- Ends loop

Again got this script below from the toolbox but changed it to how I want it

Script 3
while true do
wait(3)
C = script.Parent:Clone()
C.Position = script.Parent.Position
C.CanCollide = true
C.Anchored = true
C.Script:Remove()
C.Parent = game.Workspace.Model4.InfiniteRoad
C.Name = "Road"
end

The first script is so that way the second script doesnt get confused saying “There are no bricks!” The second script is the moving script and the third script is the cloning script. I will add in a deleting script so there wont be as much lag but I will ask that question later as an edit here. Also fyi I am also not a very good scripter

EDIT: maybe I didnt explain what I wanted correctly: I know there is something wrong with script 1 but im not sure what

EDIT 2: Hello I am back from my school and my hw is completed. I will now try to do what you all said.

14 Likes

You could try doing this 10 times in front of the player(s) constantly checking if its there if it isn’t then running the script.

I think I know what you mean but I am not a good scripter (should of proboably added that in the topic) can you try to explain what you mean

Just saying, I love what you’re doing and the concept, is it possible you could just simulate it in the game, like the wheels moving and the terrain switches so you don’t actually have to physically move in the game, I’ve had problems with this before and it’s super hard sometimes to get around this.

That is exactly what I am doing here. The wheels rotating the the ground moving in a specific direction. Plus in Bus Simulator it does the exact same thing and I found proof of it.

Hmm, quite tricky, so are landscapes the only big concern?

1 Like

If you are talking about only the road then yes. Once i get the road figured out I believe I can do the landscaping as well

I dont know if this helps any but this would make an infinite road if you only use that one part:

local PreviousPos = nil

for i = 1,100 --change 100 to the amount of times you want this looped

local ClonedPart = game.Workspace.Model4.Part:Clone()

ClonedPart.Parent = workspace
if PreviousPos == nil then
ClonedPart.CFrame = CFrame.new([POSITION OF START])
PreviousPos = ClonedPart.Position
else
ClonedPart.CFrame = CFrame.new(PreviousPos)+Vector3.new(ClonedPart.Size.X,0,0) -- this would generate a part infront of the previous one.
PreviousPos = ClonedPart.Position
wait(0.1)
end
end

Again idk if this is what you were trying to accomplish but let me know C:

2 Likes

Yeah well, I found out how to do endless terrain, but I’m pretty sure rendering would be a HUGE problem.

Actually that looks good but i have 2 questions

  1. Would i just delete all my other scripts and put this under
game.workspace.Model4.InfiniteRoad
  1. cant i just do a while true do
  1. yea you could just delete the other scripts

  2. Of course! instead of for i = 1,100, change the to while wait(0.1) do

however this may cause some lag since its loading a lot of parts haha

EDIT: you can place the script I made in ServerScriptService

If possible to reduce lag, you could have it teleport them to the start of the road and repeat to try and reduce lag for not so powerful computers. I see problems with the smoothe-ness of switching but it could work.

If you haven’t already tried it, and if i get your goal wrong, what you could try is making something like the Endless Staircase from SM64, instead of actually being endless, there was a collidable block that when hit would teleport you back, which gave the sense that it was actually endless, without being actually endless.

Exactly, and you could outreach the landscape if you want the road cycle to go on longer to reduce seeing the same objects, I’m pretty sure that’s what desert bus VR did.

ok then here we go.

local road = {}
game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
       while true do
            if road[char.HumanoidRootPart.X] == nil then
                makeroad(char.HumanoidRootPart.X)
                road[char.HumanoidRootPart.X] = true
            end
        end
    end)
end)
2 Likes

All good, good luck with you’re game it’s very good :slight_smile:

@Revelted (sorry for another mention lol) I am doing your method now but in a new model named Model4B I will include what the outcome is as an edit here anything that was named in scripts or outside of them will also have the letter “B”

Delete everything.

30 characters

oh ok good you do have the same time zone
alright imma delete that other comment after i try rev’s method I aint going to do a third mention lol i will try yours next even if rev’s method worked NOT A FOURTH REEEEEE

your method will be named Model4C and same way with the other stuff

Instead of “B” it a “C”

your method will be named Model4C and same way with the other stuff

Instead of “B” it a “C”

merging this comment with the comment up top to make this comment section look more neat