Door Tween Not Working

Hello!

I am currently trying to script an animated door. When you click on the door handle, the door opens and then a few seconds later it should close.

However it does not seem to be working.

image


image

(The weld constraints connect to the primary part)

This is the script in the door model:

local door = script.Parent.Parent
local doorHinge = door.PrimaryPart
local doorOpen = TweenInfo.new()

local doorCFrame = TweenService:Create(doorHinge, doorOpen, {
	CFrame = doorHinge.CFrame * CFrame.Angles(0, math.rad(-100),0)
})

local doorCFrameClosed = TweenService:Create(doorHinge, doorOpen, {
	CFrame = doorHinge.CFrame * CFrame.Angles(0, math.rad(0),0)
})

local ClickDetector = script.Parent.Parent.Handle.ClickDetector


ClickDetector.MouseClick:Connect(function()
	doorCFrame:Play()
	script.Parent.Open:Play()
	wait(3)
	doorCFrameClosed:Play()
	wait(1)
	script.Parent.Close:Play()

end)

I don’t know what the issue is but if anyone could help me out it would be heavily appreciated.

I don’t see an icon change when you mouse over the Handle. Put a Print(“Handle clicked”) inside the ClickDetector section of the script.

Is your hinge Part Anchored, and are the rest of the Parts Unanchored and welded to the HingePart?

Is the primaryPart moving? WeldConstraints only work for parts moved by physics objects like alignOrientation or alignPosition, but not tweens if I recall correctly.

Parts that move with Anchored Tweened parts need to be welded to them.

Yeah or they don’t move with it.
I think your suspicion about the click detector being faulty is most likely correct.
Try using an invisible part around the handle and connecting the click detector to that instead? It may be that the handle mesh’s click detection region is too small?

A WeldConstraint won’t move parts connected if one of them is moved by a tween i think. The script has to be fine because the sound is playing correctly…

If you have done every step correctly, if will still work, Here is a little guide to help u. Introduction to Tweening Models - Resources / Community Tutorials - DevForum | Roblox

1 Like

I tried a transparent Part years ago with a Decal on it years ago and it wouldn’t register the ClickDetector.
Dunno if they have changed that though.

@jxd as explained in the link that @BobbieTrooper posted, WeldConstraints are what hold Unanchored Parts to Anchored Parts that are tweened.

@SmakToj you can use a welded Motor

That’s strange… WeldConstraints don’t move both of the parts connected if only one is being affected by a tween, I just checked. Is the part you are trying to tween rotating, though?

Yeah I don’t think it’s registering the click.

image

Like I suggested earlier, try putting an invisible part around the door handle and connecting the click detector to that

Does the mouse icon change when you hover over the Part that has the ClickDetector in it?

you didnt set the amount of seconds you want it to last, probably pus something like Tweeninfo.new(1)