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!
