For days now I’ve been trying to figure out how to move an entire folder/model
I’m trying to move 1 part of a Map Generation somewhere else than the other generation.
I’ve tried Pivoting the model/folder to a certain part but it doesn’t seem to work.
The folders are corresponding to the area number you put in for the function.
function generate(colorground, colorwater, colorsand, area)
--[[ all code by okeanskiy. ]]--
--[[
Script #1 of 2: game.ServerScriptService.Terrain (Server Script)
]]
local X = 50
local Z = 50
local grid = {}
for x = 1, X do
grid[x] = {}
for z = 1, Z do
grid[x][z] = math.noise(x/10, z/10) * 15
end
end
for x = 1, X do
for z = 1, Z do
local yPos = grid[x][z]
local part = Instance.new("Part")
part.Anchored = true
if yPos < -3 then
part.Material = Enum.Material.SmoothPlastic
part.BrickColor = colorsand
else
part.Material = Enum.Material.SmoothPlastic
part.BrickColor = colorground
local attach = Instance.new("Attachment")
attach.Parent = part
attach.Position = Vector3.new(attach.Position, 16.796, attach.Position)
attach.Visible = true
end
part.Position = Vector3.new(x*5, yPos, z*5)
part.Size = Vector3.new(5, 30, 5)
part.Parent = workspace.MapGeneration
end
end
local water = Instance.new("Part")
water.Anchored = true
water.Size = Vector3.new(X*5, 30, Z*5)
water.Position = Vector3.new(((X+1)*5)/2, -5, ((Z+1)*5)/2)
water.CanCollide = false
water.Transparency = .5
water.BrickColor = colorwater
water.Parent = workspace.MapGeneration
local model = Instance.new("Model")
for _, Generation in pairs(workspace.MapGeneration:GetChildren()) do
Generation.Parent = model
model.Name = area .. "- MapGenerator"
model:PivotTo(workspace[area].DefaultPosition.CFrame)
model.Parent = workspace
print(area)
end
if area == 0 then
local spawnloc = Instance.new("SpawnLocation")
spawnloc.Anchored = true
spawnloc.Size = Vector3.new(X*5, 30, Z*5)
spawnloc.Position = Vector3.new(((X+1)*5)/2, -5, ((Z+1)*5)/2)
spawnloc.CanCollide = false
spawnloc.Transparency = .5
spawnloc.Parent = workspace
else
end
--[[
Script #2 of 2: game.ServerScriptService.RandomVsNoise (Server Script)
]]
--[[print("10 RANDOM NUMBERS:")
for i = 1, 10 do
print(math.random())
end
print("10 NUMBERS GENERATED FROM NOISE")for i = 1, 10 do
print(math.noise(i/10))
end]]
end
generate(BrickColor.new("Bright green"), BrickColor.new("Electric blue"), BrickColor.new("Cool yellow"), 1)
generate(BrickColor.new("Medium stone grey"), BrickColor.new("Electric blue"), BrickColor.new("Cool yellow"), 2)