#CFrame Rotation of a moddle

1 messages · Page 1 of 1 (latest)

random kraken
#

I have this setup and when i open the door it goes slightly -Z but then doesn't return to the origin

#
local TweenService = game:GetService('TweenService')

local doorOpen = false

local doorModle = script.Parent
local proximityPrompt = doorModle.Door.Attachment.OpenDoor
local hinge = doorModle.PrimaryPart
local hingeCfram = hinge.CFrame

local function openDoor()
    
    local goalOpen = {
        CFrame = hinge.CFrame * CFrame.Angles(0,math.rad(90),0),
    }
    
    local tweenInfo = TweenInfo.new(1,Enum.EasingStyle.Sine)
    
    local tween = TweenService:Create(doorModle.Door, tweenInfo, goalOpen)
    
    tween:Play()
    
    doorOpen = true
end

local function closeDoor()
    
    local goalClose ={
        
        CFrame = hingeCfram
    } 
    
    local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine)
    
    local tween = TweenService:Create(doorModle.Door, tweenInfo, goalClose)
    
    tween:Play()
    
    doorOpen = false
end

proximityPrompt.Triggered:Connect(function()
    
    if doorOpen then
        
        closeDoor()
    elseif not doorOpen then
        
        openDoor()
    end
end)