My goal is to make a script that will tell me if its parent brick is within a certain amount of studs from a specific spot in the terrain. Here is what I have so far:
local BRICK = script.Parent
local childPos = BRICK.Position
local t = game.Workspace.Terrain
local cellPos = t:WorldToCell(Vector3.new(childPos.x, (childPos.y - 1), childPos.z))
local x = cellPos.x
local y = cellPos.y
local z = cellPos.z
local rangeCheck = (childPos - cellPos).magnitude
print(childPos)
print(cellPos)
wait(5)
if rangeCheck <= 10 then
print("in range")
else
print("not in range")
end
The problem is, the position of the brick is correct, but the position of the terrain block is REALLLLLY far away. My question is, why does this not return the position of the terrain block closest to the brick? Thanks!

3 comments
you have to run the if statement again using while loops
wait so i should just add a simple while loop to my existing rangeCheck? why is that?
I have no clue but reading the wiki it says there are only 4x4x4 cells which would make them large