I have a script that uses BodyPosition to bring the player to their mouse's position. I'd like to set a max distance to it so that players cant just fly out of the map with it.

Example of what I have :

local BP = Instance.new("BodyPosition")
BP.D = 500
BP.P = 3000
BP.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BP.Position = mouse.p

I'd like to modify that so they can't go too far.

Thanks for reading

EDIT: Solved it using magnitude