Drag detector click

Hi, I’ve been trying to make a door with drag detectors, and I’ve ran into some issues.
If you look in the video posted the door works great, until you click.
Is there a way to detect a drag detector click, or somehow just not play the sounds when it’s clicked?
See the code below

local door = script.Parent.MainPart
local dragdetector = door.DragDetector
local dooropen = door.dooropen
local doorclose = door.doorclose

local targetOrientation = Vector3.new(0, -180, -90)
local threshold = 5

local doorOpened = false

dragdetector.DragStart:Connect(function()
	local doorat = door.DoorAtt.WorldOrientation
	local orientationDiff = (targetOrientation - doorat).Magnitude
	if orientationDiff <= threshold then
		dooropen:Play()
		doorOpened = true
	end
end)

dragdetector.DragEnd:Connect(function()
	local doorat = door.DoorAtt.WorldOrientation
	local orientationDiff = (targetOrientation - doorat).Magnitude
	if orientationDiff <= threshold and doorOpened then
		doorclose:Play()
		doorOpened = false
	end
end)

I’m not completely sure, but i think you could check the doors velocity by using a :PropertyChangedSignal(), and only play the sound if the magnitude of the velocity is above, or equals to 0. Basically if the player is dragging the door, and the velocity is greater than lets say 1, then you would play the door opening sound, now for the door closing sound i guess you could check both the velocity and the orientation of the door to determine if it was actually closed.

door:GetPropertyChangedSignal("Velocity"):Connect(function()
	if door.Velocity.Magnitude == 0 then

	elseif Part.Velocity.Magnitude > 0 then

	end
end)
2 Likes

I’ve been testing and I don’t think this works, because when you click a drag detector it moves it just slightly so the velocity.magnitude is never 0.

Then check if its under a certain value other than 0, for example.

if Velocity.Magnitude < 0.5 then

end

Thank you. This seems to work.

1 Like

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