Hello! My code is already working. I'm pretty sure that this isn't that hard to fix, but I just cant figure out what I'm doing wrong. I am new to tweening so I'm not that good at it.

I am trying to get the door to rotate around the hinge exactly, but what I currently have makes it clip through the wall.

Video

My script (also, the CFrame.new(0, -6.146, 0) makes the hatch/door part 6 studs lower otherwise it rotates around the center of the hatch/door):

hatch = script.Parent.Hatch
hinge = script.Parent.Hinge
local TweenService = game:GetService("TweenService")
local tweeninfo = TweenInfo.new(1.75, Enum.EasingStyle.Circular)

local Open = TweenService:Create(hatch,tweeninfo,{CFrame = hinge.CFrame * CFrame.Angles(math.rad(100),0,0) * CFrame.new(0, -6.146, 0)})
local Close = TweenService:Create(hatch,tweeninfo,{CFrame = hinge.CFrame * CFrame.Angles(math.rad(0),0,0) * CFrame.new(0, -6.146, 0)})

script.Parent.Detector.Touched:Connect(function()
	print("Touched")
		Open:Play()
		wait(4)
		Close:Play()
end)

Thanks for any help!

4 comments

1

Use a HingeConstraint with the "Servo" actuator type

0

You could set the hinge as the door's primary part and then just rotate the hinge!

0

that wouldn't work very efficiently as it could cause some issues in game. ure better of using hingeconstrainsts @sne