Robloxでスクリプトを用いて等間隔にパーツを生成する
元となるパーツを作成する

名前をBasePartに変更し、

作成したパーツをServerStorageの配下に配置する

ServerScriptService配下にスクリプトを作成、名前をBaseSpawnerに変更する

スクリプトを以下のように編集する
local storage = game:GetService("ServerStorage") local partBase = storage:FindFirstChild("BasePart"); -- パーツを100個等間隔に配置する for i = 1, 100 do local part = partBase:Clone() part.Parent = game.Workspace part.Anchored = true part.Position = Vector3.new(0, 0, i * 5 + 5) end
結果

BasePlateを削除し、生成間隔を調整、BasePartにランダムな色を適用すると簡易Obbyになる
local storage = game:GetService("ServerStorage") local partBase = storage:FindFirstChild("BasePart"); for i = 1, 100 do local part = partBase:Clone() part.Parent = game.Workspace part.Anchored = true -- 間隔を調整 part.Position = Vector3.new(0, 0, i * 8 + 5) -- ランダムな色を適用 part.BrickColor = BrickColor.Random() end

関連