When at a certian time of the day the door will open and at later in the day the door will close until the morning.
When the time of day hits 6pm the door is supossed to close but when it does it doesnt close completely and starts to shake back and forward but when opening it works fine.
local TweenService = game:GetService("TweenService")
local hinge = script.Parent.Hinge
local goalOpen = {}
goalOpen.CFrame = hinge.CFrame * CFrame.Angles(0, math.rad(110), 0)
local goalClose = {}
goalClose.CFrame = hinge.CFrame * CFrame.Angles(0, 0, 0)
local tweenInfo = TweenInfo.new(1)
local tweenOpen = TweenService:Create(hinge, tweenInfo, goalOpen)
local tweenClose = TweenService:Create(hinge, tweenInfo, goalClose)
local DoorOpened = false --Debounce
while true do
wait(0.1)
if game.Lighting:GetMinutesAfterMidnight() >= 6 * 60 and DoorOpened == false then
tweenOpen:Play()
DoorOpened = true
end
if game.Lighting:GetMinutesAfterMidnight() >= 18 * 60 and DoorOpened == true then
tweenClose:Play()
DoorOpened = false
end
end
External Media