Any answers as to why I can't close the door after opening it?

I made this script that opens a door when clicked with a ClickDetector, yet when I try and close it, the ClickDetector doesn’t detect anything?

local TweenService = game:GetService("TweenService")
local Info =

local door = script.Parent
local cd = door.Parent.ClickDetector

local isOpen = false

local open = {
	CFrame = door.CFrame * CFrame.Angles(0,math.rad(-90),0)

local close = {
	CFrame = door.CFrame * CFrame.Angles(0,0,0)

local doorOpen = TweenService:Create(door, Info, open)
local doorClose = TweenService:Create(door, Info, close)

	print("pressed: "..door.Parent.Name)
	if isOpen == false then
		isOpen = true
		isOpen = false

There are a few potential reasons why the ClickDetector might not be detecting clicks when you try to close the door:

  1. Make sure that the ClickDetector is positioned correctly and is not obstructed by any other objects.
  2. Check that the ClickDetector is enabled and is set to detect mouse clicks. You can do this by looking at the ClickDetector’s properties in the Properties window in Roblox Studio.
  3. Make sure that the MouseClick event is properly connected to the doorClose:Play() function. You can do this by adding a print statement or a breakpoint to the event handler to see if it is being called.
  4. Make sure that the doorClose tween is set up correctly and that the door is able to reach the target CFrame. You can check this by manually setting the door’s CFrame to the target CFrame and seeing if it moves correctly.
  5. Make sure that there are no other scripts or events that might be interfering with the door’s behavior. This could include other MouseClick events, collision events, or update events that might be modifying the door’s CFrame or other properties.
  1. I’m not entirely sure if it’s positioned
  2. Yes it is, otherwise it wouldn’t open in the first place
  3. yes, already did that, only prints when it opens, not when I try to close it
  4. yes, it works
  5. No other scripts interfering

If the ClickDetector is correctly positioned, enabled, and correctly connected to the doorClose:Play() function, and there are no other scripts or events interfering with the door’s behavior, then there may be a problem with the doorClose tween itself.

One potential issue could be that the target CFrame for the doorClose tween is not being set correctly. You can try manually setting the door’s CFrame to the target CFrame ( door.CFrame = close.CFrame ) to see if it moves correctly. If it does not move correctly, there may be a problem with the target CFrame itself or with the way that it is being calculated.

You could also try adding print statements or breakpoints to your code to see where the problem might be occurring. For example, you could try printing the door’s CFrame and the target CFrame before and after the doorClose:Play() function is called, to see if they are what you expect.

Set this up and it ran fine … Use a different folder structure however. Anyways the code part seems to work.

I think I’ve fixed it. The problem itself was the workspace (I used unions for some parts and since CollisionFidelity is set by default on “Default” I had to set it as “PreciseConvexDecomposition”).
All done now, was just a problem on my end, sorry!

Pretty sure that was it, code seems to be fine … good luck

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