Scripting an infinite running train

Ok ive been wondering how to script a train that runs endless just like that old roblox game Train Wars when players spawn on a endless running train in a desert.

1 Like

Instead of moving the train, move the land around it to make it (the train) seem like its moving. You can then delete the land once it gets far enough from the train and randomly produce more land in front of the train.

1 Like

How would I go about doing that?

I made a quick little Roblox place example:
Moving Thing.rbxl (77.2 KB)

Although its not polished it has the basics put into it. The main (and only) script is in workspace.MoveScript:

local tweenService = game:GetService("TweenService")

local baseplate = workspace.Baseplate

local startPosition = baseplate.Position

function move()
	baseplate.Position = startPosition
	local tween = tweenService:Create(baseplate, TweenInfo.new(10, Enum.EasingStyle.Linear), {Position = Vector3.new(0,-10,baseplate.Size.Z/2 - 10)})
	tween.Completed:Connect(move)
	tween:Play()
end

move()

and tweens the baseplate indefinitely.

If you were to add more flora you would have to tween that too.
I also added a little bit of anchored velocity on the baseplate so you would move away from the car if you jumped out.

Good luck and hope this guides you well.

4 Likes