Drag to Open Doors Support

Hey! I have been attempting to make doors that you click and hold then drag to open and I have got so far but have become stuck. I have been searching among the forums and have only found one person who had the same issue.

When I open the door the intended way; the script works mostly besides from the fact that it jolts shut when I grab it. The only other thing is when I try to open the door from the other side, the door opening seems to be inverted.

Here is a clip on the issues:

mouse.Button1Down:Connect(function()
	mouseDown = true

	startPos = HumanoidRootPart.Orientation.Y

end)
mouse.Button1Up:Connect(function()
	mouseDown = false

	currentDoor = nil
end)

while RunService.RenderStepped:Wait() do
	if mouse.Target ~= nil and Doors[mouse.Target.Parent] and mouseDown == false and (HumanoidRootPart.Position - mouse.Target.Position).magnitude <= 10 then
		currentDoor = Doors[mouse.Target.Parent]
	end

	if currentDoor ~= nil then
		if (currentDoor.Interactable.Position - HumanoidRootPart.Position).magnitude >= 10 then
			currentDoor = nil
		end
	end

	if mouseDown == true and currentDoor and startPos then

		local loc = HumanoidRootPart.Orientation.Y

		local delta =  loc - startPos
		if currentDoor.startCFrame and delta * 2 < 100 and delta * 2 > 0 then
			TweenService:Create(currentDoor.Hinge,doorTweenInfo,{
				CFrame = currentDoor.startCFrame * CFrame.Angles(0,math.rad(math.clamp(delta*2,0,100)),0)
			}):Play()
		elseif delta * 2 > 100 then
			currentDoor = nil
		end
	end
end
1 Like

Looking at your video, it seems like it is constantly changing the position of the door.
I suggest you store the original position of the door, and then when you open it, set the new position of the door to its original position + the amount that it has opened.
When you close the door, simply set it back to the original position.