Hello developers
im making a dance pad or something that i don’t know but my problem is, my script supposed to make a grid for the dance pad, instead its something. What I’m trying to do is cloning the group and change the children’s position by adding a Z on it. Im not too familiar in Workspace scripting cause I’m more into GUI scripting, so thank you for the help and i really appreciate it!
Script:
-- Settings
local TileOutline = false
local TileLight = false
local TileMaterial = Enum.Material.Neon
local TileAspectRatio = 4
local TilePadding = 0
local StartingPos = Vector3.new(0, 0, 0)
local X_length = 10
local Z_length = 10
local LastXPos = Vector3.new(0, 0, 0)
-- Set up
local TileFolder = Instance.new("Folder", Workspace)
TileFolder.Name = "DancePad"
for Load_X = 1, X_length do
print(Load_X)
local PartLoader = Instance.new("Part", TileFolder)
PartLoader.Position = LastXPos + Vector3.new(TileAspectRatio + TilePadding, StartingPos.Y, StartingPos.Z)
PartLoader.Anchored = true
PartLoader.Size = Vector3.new(TileAspectRatio, 0.25,TileAspectRatio)
PartLoader.Material = TileMaterial
PartLoader.BrickColor = BrickColor.Black() -- Starting Color
LastXPos = PartLoader.Position
task.wait(0.1)
end
local RowGroup = Instance.new("Model", TileFolder)
RowGroup.Name = "RowGroup"
for _, GroupParts in pairs(TileFolder:GetChildren()) do
if GroupParts:IsA("Part") then
GroupParts.Parent = RowGroup
end
end
local LastZPos = Vector3.new(0, 0, 0)
for Load_Z = 1, Z_length - 1 do
local NewRow_Z = RowGroup:Clone()
NewRow_Z.Name = NewRow_Z.Name..Load_Z
NewRow_Z.Parent = TileFolder
for _, ChangePadPos in pairs(NewRow_Z:GetChildren()) do
ChangePadPos.Position = LastZPos + Vector3.new(ChangePadPos.Position.X, 0, TileAspectRatio + TilePadding)
LastZPos = ChangePadPos.Position
end
end
Expected:
Grid
Results:
Not grid
Line I’m confused on:
local LastZPos = Vector3.new(0, 0, 0)
for Load_Z = 1, Z_length - 1 do
local NewRow_Z = RowGroup:Clone()
NewRow_Z.Name = NewRow_Z.Name..Load_Z
NewRow_Z.Parent = TileFolder
for _, ChangePadPos in pairs(NewRow_Z:GetChildren()) do
ChangePadPos.Position = LastZPos + Vector3.new(ChangePadPos.Position.X, 0, TileAspectRatio + TilePadding)
LastZPos = ChangePadPos.Position
end
end
Also if i change ChangePadPos.Position.X
to 0
in line 38, it will just make it like this: