I want to drag the object with the mouse, it works fine as is however I want to limit how far the item can be dragged from the player, I want the item to be moved within a certain radius around the player like 20 studs or so.
Edit: I also want to keep the original position on the Y axis so that the part stay on the ground instead of floating up in the air.
I think your best bet would be to calculate this before you set it’s CFrame.
So, some example code could be like…
local original_Y = BPCopy.CFrame.Y
function Update_CFrame()
local new_CF = CFrame.new(mouse.Hit.X, original_Y, mouse.Hit.Z)
if (BPCopy.CFrame.p - new_CF.p).Magnitude < 20 then
BPCopy.CFrame = new_CF
end
end