-- Vars
local bonesTable = script.Parent.Plane:GetChildren()
local ControlPoint = workspace.ControlPoint
-----------------------
-- Remove Exception
local exceptionIndex = table.find(bonesTable, "Exception")
table.remove(bonesTable, exceptionIndex)
print(bonesTable)
-----------------------
-- Test Laser Properties
local testLaser = Instance.new("Part")
testLaser.CanTouch = false
testLaser.Anchored = true
testLaser.Transparency = 0
testLaser.Color = Color3.new(1, 0.423529, 0.137255)
--
for key, bone in bonesTable do
local boneDistanceFromPoint = (ControlPoint.Position - bone.Position).Magnitude
local newLaser = testLaser:Clone()
newLaser.Parent = workspace
print(bone.Name .. " is " .. boneDistanceFromPoint .. " studs away from ControlPoint.")
local startcf = CFrame.new(bone.Position, ControlPoint.Position) -- Finding the CFrame between the two parts
local cf = startcf:ToWorldSpace(CFrame.new(0,0,-boneDistanceFromPoint/2))
newLaser.CFrame = cf
newLaser.Size = Vector3.new(2,2,boneDistanceFromPoint)
end
How the bones look:
The result:
What I expected:
Any idea? Please explain in detail as I am looking to learn, not to copy paste.