AssemblyLinearVelocity refuses to work

So, I’m trying to make an object, where, if it is rotated, it’s edges continue to push loose objects towards the center. These objects are consistently generated. However, for some reason, it just simply refuses to work, ending up with strange positions and changing in different ways every time. Anyone know what’s going on?
The code:

local object = script.Parent:GetChildren()
local nameSplit

local function findBorders()
	for i, v in pairs(furnace) do
		nameSplit = string.split(v.Name, "_")[2]
		if nameSplit == "Borders" then return v end
	end
end

local function findTop()
	for i, v in pairs(furnace) do
		nameSplit = string.split(v.Name, "_")[2]
		if nameSplit == "MainTop" then return v end
	end
end

local borderGroup = findBorders():GetChildren()

local objectTop = findTop()

objectTop:GetPropertyChangedSignal("Orientation"):Connect(function()
	for i, v in pairs(borderGroup) do
		if v.Position.X - objectTop.Position.X < 0 then
			v.AssemblyLinearVelocity = Vector3.new(3, 0, 0)
			print(v.Name .. " Front")
		elseif v.Position.X - objectTop.Position.X > 0 then
			v.AssemblyLinearVelocity = Vector3.new(-3, 0, 0)
			print(v.Name .. " Back")
		elseif v.Position.Z - objectTop.Position.Z < 0 then
			v.AssemblyLinearVelocity = Vector3.new(0, 0, 3)
			print(v.Name .. " Right")
		else
			v.AssemblyLinearVelocity = Vector3.new(0, 0, -3)
			print(v.Name .. " Left")
		end   
	end
end)

(Long if-else statement because I just want to get it to work before I improve it.)

The primary part of the group is being rotated, so everything is being rotated 90 degrees at a time.

2 Likes

Right on the page for AssemblyLinearVelocity it says:

Setting the velocity directly may lead to unrealistic motion. Using a VectorForce constraint is preferred, or use BasePart:ApplyImpulse if you want instantaneous change in velocity.

You can also try body movers

This is meant to move loose parts that are traveling down a conveyer, not sure how I would use VectorForce to do that, as it seems to only effect anchored parts in specific ways. I want mine to be able to effect loose parts in many ways.

I think you can just set the velocity in general. I remember seeing this on a conveyor

I ended up solving this myself. When looking through the properties of CFrame, I saw one called lookVector, and ended up using it to fix the whole thing. :man_shrugging: