Hi, I am making a system of beams connecting between HumanoidRootPart and V but I have a little problem with magnitude because my script takes magnitude of two V at once and if I’m near one of the V the beam doesn’t connect because the other V is too far.
Is there any possibility of specifying the magnitude of only one V at a time?
Short video about issue:
local Player = game:GetService("Players").LocalPlayer
local HumanoidRootPart = Player.Character:WaitForChild("HumanoidRootPart")
local Beam = Instance.new("Beam")
local Attachment0 = Instance.new("Attachment")
local Attachment1 = Instance.new("Attachment")
while true do wait()
for i, v in pairs(game.Workspace.Lights:GetDescendants()) do
if v.Name == "BasePartS" then
if (HumanoidRootPart.Position - v.Position).magnitude < 50 then
Attachment0.Parent = HumanoidRootPart
Attachment1.Parent = v
Beam.Parent = HumanoidRootPart
Beam.Attachment0 = Attachment0
Beam.Attachment1 = Attachment1
print(">50")
else
Beam.Attachment1 = nil
print("<50")
end
end
end
end