How to clamp a dragdetector?

I’ve been experimenting with the usage of DragDectors (the 3d ones), and I’ve mostly got them down but I wanted to know how to clamp them, or stop them moving from a specific threshold?


Something like this specifically? Any advice would help.

this video could help u

I watched that video but it only went into detail over the regards of flip switch, or a radial lever whatever u wanna call it.

It may be worth looking at
MaxDragTranslation

I know for my use case where I needed to clamp movement within a changing 3d space I had to use a constraint function DragDetector | Documentation - Roblox Creator Hub

I tried using MaxDragTranslation, while its a little helpful it didnt really “stop” the actual item, could you tell me more about the constraint function you used? I was curious about that but I wasnt sure how to implement.

They have a decent example in their DragDetector Custom Constraint Function article here
But the gist is it’s a function that takes a the proposed CFrame, where the item would normally be based off the drag, and you have it return whatever CFrame you want.
So you would add your positioning check into the contraint function.

Roughly:

local function checkPos(proposedMotion)
	local propPos = proposedMotion.Position
	if propPos .Y > 3 then
           return CFrame.new(Vector3.new(propPos.X, 3, propPos.Z) * proposedMotion.Rotation)
       end
end

local connection = dragDetector:AddConstraintFunction(2, checkPos)
1 Like