Dragdetector max range?

What i mean by the title is that currently, my dragdetector will not stop dragging even if its 200000 studs away. (this is overexaggerated but it works like that) I want to know if there is a property that can set the range. Ive checked the documentation but there was nothing about range (except activation range). I want the dragdetector to stop dragging if the player is atleast 20 studs away from the draggable part.

1 Like

You need to set MinDragTranslation and MaxDragTranslation to how far you want the player to be able to move the part (this will be from the parts current position). You can set the RefereceInstance to some part that cant be moved if you want it to always be bound to some area (as if you dont have ReferenceInstance set its starting position will reset every time you stop holding it). If you want it to be from the player you can set the drag detectors ReferenceInstance to the players HumanoidRootPart on drag start:

local drag = script.Parent

drag.DragStart:Connect(function(player)
	local root = player.Character.HumanoidRootPart
	drag.ReferenceInstance = root
end)

drag.DragEnd:Connect(function()
	drag.ReferenceInstance = nil
end)

If you want it to stop you from holding it if its too far you can connect DragContinue and check the distnace of the part from the player by doing:
(part.Position - player.Character.HumanoidRootpart.Position).Magnitude > 20
and disabling and re-enabling the drag detector.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.