I have been looking on the forum for anything which may help my issue. My main focus is for the beam to go invisible (Visible = false) when it reaches a certain distance. So if the range is set to 10 and the Beam is longer than 10 studs it goes invisible.
Is this possible? I just need some help and support on this issue I am having.
Grab the .Magnitude of both the beam’s attachments’ positions. Something like this;
local MaxLength = 10
local ExampleBeam = [Beam]
function GrabLength(ExampleBeam)
if ExampleBeam and typeof(ExampleBeam) == 'Instance' and ExampleBeam.ClassName == 'Beam' then
return math.abs((ExampleBeam.Attachment0.WorldPosition - ExampleBeam.Attachment1.WorldPosition).Magnitude)
end
end
function CheckBeam()
local BeamLength = GrabLength(ExampleBeam)
if BeamLength > MaxLength then
ExampleBeam.Enabled = false
elseif not ExampleBeam.Enabled then
ExampleBeam.Enabled = true
end
end