local script in starter player scripts:
game.Players.LocalPlayer.CharacterAdded:Connect(function(character)
local root = character:WaitForChild("HumanoidRootPart")
local a0 = root:WaitForChild("RootRigAttachment")
print("Character and root attachment found:", root.Name)
task.wait(1) -- Small delay to ensure everything is loaded
module.castBeam(a0, character, game.Workspace:WaitForChild("test"))
task.wait(3)
module.castBeam(a0, character, game.Workspace:FindFirstChild("WORK"))
task.wait(2)
module.castBeam(a0, character, game.Workspace:FindFirstChild("Part2"))
end)
module script in replicated storage:
function module.castBeam(a0, char, target)
print('executed')
if char:FindFirstChildOfClass("Beam") then
char:FindFirstChildOfClass("Beam"):Destroy()
end
local beam = script:WaitForChild("Beam"):Clone() -- Create a clone of our template
local attachment = Instance.new("Attachment", target)
local a1 = target:FindFirstChildOfClass("Attachment") -- Find the attachment in the part
-- Debug: Check the distance between attachments
if a0 and a1 then
local distance = (a0.WorldPosition - a1.WorldPosition).Magnitude
print("Distance between attachments: ", distance)
end
if a1 then -- If we found one, attach it
beam.Attachment0 = a0 -- Set attachments
beam.Attachment1 = a1
-- Set beam properties for visibility
beam.Width0 = 2
beam.Width1 = 2
beam.Color = ColorSequence.new(Color3.fromRGB(255, 0, 0)) -- Red color
beam.Transparency = NumberSequence.new(0) -- Fully opaque
beam.Parent = char -- Or use workspace, depending on the setup
print("Beam attached between:", a0.Parent.Name, "and", a1.Parent.Name)
else -- If there isn't one, let the scripter know
warn("No attachment was inserted into "..target:GetFullName())
end
end
return module
as you see there are many comments on the script, that’s because i tried to use ai for debugging after it did not work regardless of anything I did, it still does not work, all the debug print commands print what they should be printing but the beam is invisible, the scripts run as intended, the attachments are made in the parts, the beam clone is parented to my character and its properties are all fine, as in the beam should be visible but regardless of anything i tried, its never visible
edit: I also just tried manually casting a beam between 2 set attachments and copied the beams properties from a YouTube video on beams so that the properties being set in such a way that would make the beam invisible would be impossible, wouldn’t you guess it the beam is still nowhere in sight despite copying exactly what the video showed. I don’t know what it could be at this point besides some studio bug.