Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Nodes = workspace:WaitForChild("Nodes")
- local Table = Nodes:GetChildren()
- function Connect()
- for _,A in ipairs(Table)do
- -- Don't overfill the nodes with neighbors.
- if #A:GetChildren() <= 0 then
- for _,B in ipairs(Table)do
- if B ~= A then
- -- Make sure the path can be completed.
- local P = workspace:FindPartOnRay(Ray.new(A.Position, B.Position - A.Position))
- if P == B then
- local Neighbor = Instance.new("ObjectValue")
- Neighbor.Value = B
- Neighbor.Name = "Neighbor"
- Neighbor.Parent = A
- end
- end
- end
- end
- end
- end
- Connect()
Advertisement
Add Comment
Please, Sign In to add comment