Is there a way to get the distance between two objects? I looked for this on the wiki but I didn't find anything. If it is possible, I want to make is so that if an object gets within a certain distance, something would happen.
If checking the distance between a player and an object:
function getDistance(player, object) return player:GetDistanceFromCharacter(object.Position) end
Otherwise, use the following.
function getDistance(object1, object2) return (object1.Position - object2.Position).magnitude end
Both functions return the distance in studs between the two objects (or player and object).