Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I get a door to rotate around a hinge?

Asked by 3 years ago

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!

1
Use a HingeConstraint with the "Servo" actuator type Rare_tendo 3000 — 3y
0
You could set the hinge as the door's primary part and then just rotate the hinge! sne_123456 439 — 3y
0
that wouldn't work very efficiently as it could cause some issues in game. ure better of using hingeconstrainsts @sne JesseSong 3916 — 3y

Answer this question