I tried making a circle as a limiter for the object and added a TouchEnded function, but that’s broken, believe me, the other scripters saying it sucks
I tried searching on youtube but I don’t see anything
How do I do this?
What I’m trying to script here is if the object gets too far from it’s old position, it prints something
--Get RestPositionOfObject--
--If Object.Position > RestPositionOfObject + RadiusLimit(IDK how do to that) then
--Print "Object got too far"
--End--
local object = game.Workspace.Object -- Reference for the object
local origin = Vector3.new(0, 0, 0) -- Default position of the object
local threshold = 15 -- Maximum distance the object can be away from its origin
object:GetPropertyChangedSignal("Position"):Connect(function() -- This function will run every time the objects position changed
local distance = (object.Position - origin).Magnitude -- Calculate the distance from the origin to the new position
if distance >= threshold then -- Will execute the code below if the object moved out of that threshold
print("Object moved out of threshold from origin!")
end
end)
local MAX_DISTANCE = 20
local distance = math.abs((A.Position - B.Position).Magnitude)
if distance > MAX_DISTANCE then
-- code here
end
Actually, I’m trying to limit the object position to the radius/distance using the x² + y² = r² formula - know in Portuguese as (Equação Reduzida da Circunferência)