I'm currently trying to make a block which, depending on the proximity of blocks below, will adjust it's own Y position. At the moment, I'm making the part in which it will raise it's Y position if it's too close to the block below.
The system I'm using is a sensor block (known as 'frf' in the code) which sits not far below the main block (known as 'fr' in the code). The code is supposed to detect whether the sensor block is colliding with anything and, if it is, adjust the height of both blocks by 0.1 then continue checking forever and adjusting the height where necessary.
Unfortunately, when I run the code, both blocks just continue rising infinitely and I cannot see how this would happen. Thoughts?
Here is my code:
local fr = workspace.Drone["Front Right"]
local frf = workspace.Drone["Front Right Floor"]
local arlen = 0
local ar = {frf:GetTouchingParts()}
local ar = 0
while true do
ar = {frf:GetTouchingParts()}
arlen = 0
for key, values in pairs(ar) do
arlen = arlen + 1
end
while arlen > 0 do
fr.Position = fr.Position + Vector3.new(0,0.1,0)
frf.Position = frf.Position + Vector3.new(0,0.1,0)
arlen = 0
wait(0.05)
end
end
Thanks in advance for any help!

1 comment
You should use better names for your variables so when you are typing code and checking it you can easily tell what a variable means.