How do I attach the ends of models together? Similar to Archimedes for example?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’m looking to make a way to tile the ends and starts of models together.

  2. What is the issue? Include screenshots / videos if possible!
    I’ve tested the game and when models spawn I notice that they seem to not spawn on the end of the other model but instead on the inside, clipping through. I have created a boundary box for the model to let it tile easier but it’s not working!

  3. What solutions have you tried so far? Did you look for solutions on the Creator Hub?
    As mentioning before, I have tried to use a boundary box. I also did some research.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DefaultService = workspace:FindFirstChild("Default")
local Debris = game:GetService("Debris")
local RunService = game:GetService("RunService")

local Assets = ReplicatedStorage:FindFirstChild("EnvironmentModels")
local TunnelModel = Assets and Assets:FindFirstChild("TrainTunnel")
local SceneModels = Assets and Assets:FindFirstChild("Scenes")
local _Render = DefaultService and DefaultService:FindFirstChild("_Render")
local EnvironmentFolder = _Render and _Render:FindFirstChild("Environment")

local CurrentScene = "Cliffside"

local ModelLifetime = 70
local GenerationRate = 2
local EnvironmentSpeed = 20
local MaxDistance = 2000

local LastTile = nil
local Transitioning = false

local MovingTiles = {}
local TileCounters = {}

local function AddMovingTile(tile)
	if tile and tile:IsDescendantOf(EnvironmentFolder) then
		MovingTiles[tile] = true
	end
end

local function RemoveMovingTile(tile)
	MovingTiles[tile] = nil
end

RunService.Heartbeat:Connect(function(dt)
	for tile, _ in MovingTiles do
		if tile and tile.Parent and tile.PrimaryPart then
			local currentCFrame = tile.PrimaryPart.CFrame
			local newCFrame = currentCFrame + Vector3.new(-EnvironmentSpeed, 0, 0)
			tile:PivotTo(newCFrame)

			if math.abs(newCFrame.Position.X) > MaxDistance then
				RemoveMovingTile(tile)
				tile:Destroy()
			end
		else
			RemoveMovingTile(tile)
		end
	end
end)

local function SpawnTunnelTile()
	local tunnel = TunnelModel and TunnelModel:Clone()
	if not tunnel then return end
	if tunnel:FindFirstChild("BoundingBox") then tunnel.PrimaryPart = tunnel:FindFirstChild("BoundingBox") end
	tunnel.Parent = _Render
	AddMovingTile(tunnel)
	Debris:AddItem(tunnel, ModelLifetime)
end

local function getTileCounterKey(sceneName, variantName)
	return tostring(sceneName) .. "_" .. tostring(variantName)
end

local function SpawnSceneTile()
	local sceneFolder = SceneModels and SceneModels:FindFirstChild(CurrentScene)
	if not sceneFolder then return end
	local modelsFolder = sceneFolder:FindFirstChild("Models")
	local allTiles = modelsFolder and modelsFolder:GetChildren()
	if not allTiles or #allTiles == 0 then return end

	local chosenTile = allTiles[math.random(1, #allTiles)]
	local variantName = chosenTile.Name
	local counterKey = getTileCounterKey(CurrentScene, variantName)
	
	if not TileCounters[counterKey] then
		TileCounters[counterKey] = 1
	else
		TileCounters[counterKey] = TileCounters[counterKey] + 1
	end
	
	local tileCounter = TileCounters[counterKey]

	local randomTile = chosenTile:Clone()
	randomTile.Name = string.lower(CurrentScene) .. "_" .. variantName .. "_" .. tostring(tileCounter)

	local boundingBox = randomTile:FindFirstChild("BoundingBox")
	
	if boundingBox then randomTile.PrimaryPart = boundingBox end
	randomTile.Parent = EnvironmentFolder

	if LastTile and LastTile.PrimaryPart and randomTile.PrimaryPart then
		local lastBox = LastTile.PrimaryPart
		local newBox = randomTile.PrimaryPart
		
		local lastSize = lastBox.Size.X
		local newSize = newBox.Size.X
		
		randomTile:PivotTo(newBox.CFrame * CFrame.new(Vector3.new((lastSize/2) + (newSize/2), 0, 0)))
	end

	LastTile = randomTile
	AddMovingTile(randomTile)
	Debris:AddItem(randomTile, ModelLifetime)
end

task.wait(5)

if Assets and Assets:FindFirstChild("ChangeScene") then
	Assets.ChangeScene.OnClientEvent:Connect(function(NewScene)
		if SceneModels and SceneModels:FindFirstChild(NewScene) then
			LastTile = nil
			Transitioning = true
			SpawnTunnelTile()
			task.wait(8)
			if _Render and _Render:FindFirstChild("Environment") then
				_Render.Environment:ClearAllChildren()
			end
			task.wait(3)
			CurrentScene = NewScene
			SpawnSceneTile()
			Transitioning = false
		end
	end)
end

while true do
	if not Transitioning then
		if LastTile == nil then
			SpawnSceneTile()
		else
			SpawnSceneTile()
		end
	end
	task.wait(GenerationRate)
end

Got it working after altering the pivot!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.