I have this simple black hole script that'll pull any brick in the PartStorage called "Rainbow Brick" towards it only if the Y value of it's position is less than 19.5. The output gives no error but each part called RainbowBrick doesn't have a BodyPosition child. Can anyone help me spot the problem?
local hole = script.Parent
local child = {}
for _, v in pairs(workspace.PartStorage:GetChildren()) do
if v.Name == 'Rainbow Brick' then
table.insert(child, v)
end
end
for _, v in pairs(child) do
if v.Anchored==false and v.Position.Y<=19.5 then
local relPos = hole.Position - child.Position
local motivator = child:FindFirstChild("BlackHole Influence")
if relPos.magnitude<=25 then
if motivator == nil then
motivator = Instance.new("BodyPosition")
motivator.Parent = child
motivator.Name = "BlackHole Influence"
end
motivator.position = hole.Position
motivator.maxForce = 500
end
end
end
Thanks in advance

1 comment
I see that you tried adding in the bodyposition right when the table detects it, but that sorta defeats the purpose of the second half of the script. But no sorry it didn't work still