Hello! Hope everyone is doing well.
I have been trying to make a script where it adds a border around a part with a script with the width set to a variable . However, I have been debugging for 1.5 hours so far and I just couldn’t get it to work. It got so bad, where I had to ask ChatGPT and not even it could fix it.
If anyone needs the size of the part I want the border set to, it is: 7, 1, 14
local mainPart = game.Workspace.StuddedPart
local studWidth = 1 -- width of the border
local function addBorder(x : BoolValue, z : BoolValue)
if x then
-- fill out later
end
if z then
local offset = -2.5 + (1.5 * (studWidth - 1)) -- formula (not working)
local borderPos = mainPart.CFrame + Vector3.new(0, 0, offset) -- gets the position of the border
local p = Instance.new('Part')
p.Parent = game.Workspace
p.Size = Vector3.new(mainPart.Size.X, mainPart.Size.Y, studWidth) -- Makes the width of the border be studLength
p.CFrame = borderPos -- sets the border part to the border position
end
end
addBorder(false, true) -- For now, only sets the border on the Z axis
On the image above, you can see that the part is 5 studs away from where it is supposed to be. I don’t know if it is the formula or it is just roblox at this point.
I would mess with the formula offset
, since it is completely broken.
This entire script is supposed to be redone into a plugin so it could make my life easier for an obby I am making, without having to manually change the size every time.
If anyone has any solutions or recommendations, I would love to hear you out!