Drag Detector Help

Hey everyone! Need some help, I’m trying to make it so once the lever reaches a specific angle it does a function, how do I achieve this?

script.Parent.DragDetector.DragContinue:Connect(function()
	local object = script.Parent.PrimaryPart
	local _, pitch, _ = object.CFrame:ToOrientation() 

	local pitchInDegrees = math.deg(pitch)


	if pitchInDegrees == 89.95331133131195 then
		print("Successfully dragged!")
	end
end)
1 Like

i never used dragdetectors so i dont really know how they function but maybe try to check the orientation of the lever and when it reaches a certain value it does the function?

maybe something like:

	if object.Orientation.X == 89.95 then
		print("Dragged")
	end
3 Likes

Appreciate the help! Tried this; modified it a few times, and was not the answer, sorry!

if pitchInDegrees >= 89.95331133131195 then
		print("Successfully dragged!")
	end
1 Like

Not the answer! It does work, but if i move it slightly it activates it doesn’t do it on the exact angle.

2 Likes

maybe math.round? idk but it could work

2 Likes

Why is the angle so so specific

2 Likes

Think of it this way; a door in medieval games; when you pull down the lever entirely the door opens, that’s what im trying to go for; im making it so once it reaches to the angle; it does a function.

2 Likes

iirc that long of a decimal will get rounded, so I think you will never reach that angle, try doing 89.953 instead

2 Likes

“once”, so still do >= instead of ==

2 Likes

Does not do it sadly, i tried it the drag detector does the function early.

2 Likes

Also, the signal might not be able to catch up to each drag of decimal point, thats why you would round the number

2 Likes

print pitchDegree and see how many decimals it provides you

3 Likes

Printed it, output is 89.95760069011072.

2 Likes

print at each trigger, see if your degree pops up

2 Likes

Nope this time it’s different! 89.9559204635749 changes each time i pull the dragdetector down.

2 Likes

yeah it’s pretty capture the exact angle, its clear that its pretty good to capture 89.95, therefore you should try >= 89.95 or 89.9

1 Like

That’s the issue tthough: if i move the angle all the way up its 89.97413657809133 to its defaultt position.

1 Like

May I see what you are doing exactly?

1 Like

As in script wise or do you want a recording?

1 Like