Help fix this scripting issue

I made a plugin and it makes stairs

local toolbar = plugin:CreateToolbar("Stairs Builder")

local button = toolbar:CreateButton("Create Stairs","Make stairs for selected part","rbxassetid://4458901886")
local selection = game:GetService("Selection")

button.ClickableWhenViewportHidden = true
local currentpart = nil
local changehistoryservice = game:GetService("ChangeHistoryService")

local function createstairs()
    local selectedobjects = selection:Get()
    if #selectedobjects == 1 then
        local model = Instance.new("Model",workspace)
        model.Name = "Stairs"
        currentpart = selectedobjects[1]
        for i = 1,50 do
            local part = Instance.new("Part",model)
            part.Material = currentpart.Material
            part.Anchored = currentpart.Anchored
            part.BrickColor = currentpart.BrickColor
            part.Size = currentpart.Size
            part.CFrame = currentpart.CFrame + currentpart.CFrame.LookVector*currentpart.Size.X*i + currentpart.CFrame.UpVector*currentpart.Size.Y*i
        end
        changehistoryservice:SetWaypoint("Added Stairs")
    end
end

button.Click:Connect(createstairs)

Now I want the front side of part to get stairs, it works

but the cframe is wrong, its creating with random distance
i want to know which axis is front and back of a part, example: size = 2,1,4, how do I know which is front-back axis of the part, so i can keep the distance between stairs

1 Like