How to correctly use BodyPosition?
Alright so here's what I have so far. I have bricks, called "Rainbow Bricks", located in a PartStorage model in the workspace. I'm trying to build a circular conveyor belt, with everything that lands on it going towards the middle. I think the easiest way to do that is to make the center part of the conveyor, the collector, have some sort of black hole script to pull only those certain bricks in towards it. Now here's what I know
1 | if object is rainbow brick, then add it into a table |
2 | if the relative position (collector position - part position) is less than 25 then |
3 | insert a BodyPosition into the children with less than 25 relPos |
4 | BodyPosition.position = collector.position |
5 | BodyPosition.maxForce = x |
Seems simple enough, right? Well here's my attempt
01 | local hole = script.Parent |
04 | function checkObject(obj) |
05 | if (obj ~ = hole) and (obj.className = = "Part" ) and obj.Name = = "Rainbow Brick" then |
06 | if (obj.Anchored = = false ) then |
07 | table.insert(childList, 1 , obj) |
13 | local child = childList [ n ] |
14 | if (child ~ = hole) and (child.className = = "Part" ) and (child.Anchored = = false ) and (child.Name = = "Rainbow Brick" ) then |
15 | local relPos = hole.Position - child.Position |
16 | local motivator = child:FindFirstChild( "BlackHole Influence" ) |
17 | if relPos.magnitude < 25 then |
18 | if motivator = = nil then |
19 | motivator = Instance.new( "BodyPosition" ) |
20 | motivator.Parent = child |
21 | motivator.Name = "BlackHole Influence" |
23 | motivator.position = hole.Position |
24 | motivator.maxForce = 200 |
26 | elseif child.motivator ~ = nil then |
27 | child.motivator:Remove() |
No errors in the output, nothing is happening. I'm sorry if this script is terrible. I'm still a beginner.