Sorry if my wording was wrong, think of the ground as a baseplate. Whenever the player gets close to the edge of the baseplate, it creates a new baseplate that would be infront of the previous baseplate
Perosnally, since the texture on the baseplate is an 8x8 texture (if im not mistaken) i would do something like this:
It doesnt generate ground but it keeps the ground positioned around the player
local Base = game.Workspace.BasePlate
local RunService = game:GetService("RunService")
local GridSize = 8
RunService.Heartbeat:Connect(Function()
if not game.player.LocalPlayer.Character then return end
if not game.player.LocalPlayer.Character.HumanoidRootPart then return end
local PlayerPos = game.player.LocalPlayer.Character.HumanoidRootPart.Position
local NewPos = vector3.new(math.round(PlayerPos.X / GridSize) * GridSize, Base.Position.Y, math.round(PlayerPos.Z / GridSize) * GridSize)
Base.Position = NewPos
end)
if you want an easy solution, just make a part at the end of some rails, and when the part is touched, put more rails in front.
local touchPart = game.Workspace.Part
local endPart = game.Workspace.EndPart
touchPart.Touched:Connect(function()
local newRail = script.Rail:Clone()
newRail:PivotTo(endPart.CFrame)
touchPart = newRail.part
endPart = newRail.endPart
-- just example, but you get it
end)