Hi quick issue I don’t understand how to fix. I am trying to clone multiple parts and beams. I have one function for cloning and one function for dealing with beams. When running the code I release that it’s indeed finding applying the Attachment0 and Attachment1 properly in the server but it’s only working for 1 beam. The second one beam is being set up properly but visual it’s not showing the beam with attachments even tho the right attachments are there…
Visual example of the issue: Watch 2024-03-28 17-11-56 | Streamable
this is what I use
local function cloneComponentsToPlayerAndTrackBeams(auraComponent, playerComponent, clonedBeams)
for _, auraChild in pairs(auraComponent:GetChildren()) do
local playerChild = playerComponent:FindFirstChild(auraChild.Name)
if not playerChild then
local clonedComponent = auraChild:Clone()
if clonedComponent:IsA("Beam") then
table.insert(clonedBeams, clonedComponent)
end
clonedComponent.Parent = playerComponent
else
cloneComponentsToPlayerAndTrackBeams(auraChild, playerChild, clonedBeams)
end
end
end
local function updateBeamAttachments(clonedBeams)
for _, beam in ipairs(clonedBeams) do
local startAttachment = beam.Parent:FindFirstChild("Start1")
local endAttachment = beam.Parent:FindFirstChild("End1")
if startAttachment and endAttachment then
beam.Attachment0 = startAttachment
beam.Attachment1 = endAttachment
else
warn("One of the beam's attachments is missing: Start1 or End1.")
end
end
end
This is how I call it
local auraModel = script:WaitForChild('natsuTransform')
local clonedBeams = {}
print(clonedBeams)
cloneComponentsToPlayerAndTrackBeams(auraModel, Char, clonedBeams)
updateBeamAttachments(clonedBeams)