Hey! I’m trying to make these conveyors that can be placed by the user and it has a beam with attachments that make a moving animation (eg:)
But when you I multiple up, sometimes the beams glitch at the ends of the conveyors and it’s very mildly infuriating to me. It does get worse than that but it just goes away too fast to get a high enough quality screenshot and I don’t know how to record my screen on this laptop lmao
I don’t really know where to start with trying to line them up effectively, I wanted to do a magnitude check for the beginnings and endings of each conveyor and then link the beginning beam and whatever but my brain hurts trying to write that code.
I got here and then basically had a stroke and decided to make this post:
local getNearest = function(con,list)
local lim = 0.25;
local linked = {};
for _,conveyor in pairs(list) do
if(conveyor ~= con) then
local endPart = (con.Start.Position - conveyor.End.Position).magnitude;
local startPart = (con.End.Position - conveyor.Start.Position).magnitude;
if(endPart <= lim or startPart <= lim) then
linked[conveyor] = true;
end
end
end
print(linked)
end
local linkBeams = function(conveyor)
local objects = conveyor.Parent:GetChildren();
local linked = conveyor:GetAttribute("LinkedModule"); -- ignore this, basically makes sure it's actually a conveyor lol
local total = {};
for _,object in pairs(objects) do
if(object:GetAttribute("LinkedModule") == linked) then
table.insert(total,object);
end
end
if(#total >= 1) then
for _,con in pairs(total) do
local nearest = getNearest(con,total)
end
end
end
Does anyone have any posts similar to this one? I couldn’t find any because it’s so oddly specific, and if there’s a better solution to my problem please tell me. I just don’t know what to do from here.