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.