CFrame.Angles Stuff

Hi. I’m having issue with figuring out the below.
At the moment when activated the DoorRoot moves to 90 degrees.
I’m trying to make it increase by 90 degrees, not move to 90 degrees.

Any help is appreciated.

local DoorOpen = TweenService:Create(DoorRoot, DoorSwingInfo, {
CFrame = DoorRoot.CFrame * CFrame.Angles(0, math.rad(90), 0)
})

1 Like

Is the DoorOpen Tween Played?

ie.

DoorOpen:Play();

It would be handy if you provided a sufficient amount of code to assist you.

I don’t know if it really glitch out for you or something, but to be exact,
just don’t do math there to avoid glitches

local doortargetcframe =  DoorRoot.CFrame * CFrame.Angles(0, math.rad(90), 0)
local DoorOpen = TweenService:Create(DoorRoot, DoorSwingInfo, {
CFrame = doortargetcframe
})

but if that isn’t the case, I can’t help you

Helped on discord since we’re in the same server.

Original code
local Door = script.Parent.Parent
local DoorRoot = Door.PrimaryPart
local PositionPart = Door.Position

local Distance = 4.6

local DoorSwingInfo = TweenInfo.new()

local Value = false

local DoorOpen = TweenService:Create(DoorRoot, DoorSwingInfo, {
    CFrame = Door.CFrame * CFrame.Angles(0, math.rad(90), 0)
})

local DoorClose = TweenService:Create(DoorRoot, DoorSwingInfo, {
    CFrame = Door.CFrame * CFrame.Angles(0, math.rad(0), 0)
})

RemoteEvent.OnServerEvent:Connect(function(Player)
    local Character = Player.Character
    if (Character.HumanoidRootPart.Position - PositionPart.Position).Magnitude <= Distance then 
        if Value == false then
            Value = true
            DoorOpen:Play()
        else
            Value = false
            DoorClose:Play()
        end
    end
end)
Edited code
local Door = script.Parent.Parent
local DoorRoot = Door.PrimaryPart
local PositionPart = Door.Position

local Distance = 4.6

local DoorSwingInfo = TweenInfo.new(.5)

local Value = false

local RootCF = DoorRoot.CFrame

function TweenDoor(Direction)
  TweenService:Create(DoorRoot, DoorSwingInfo, {CFrame = RootCF * CFrame.Angles(0, math.rad(90) * Direction, 0)}):Play()
end

RemoteEvent.OnServerEvent:Connect(function(Player)
    local Character = Player.Character
    if (Character.HumanoidRootPart.Position - PositionPart.Position).Magnitude <= Distance then 
        if Value == false then
            Value = true
            TweenDoor(1)
        else
            Value = false
            TweenDoor(0)
        end
    end
end)

Summary: Simply made a function for him which would work with different directions and more control instead of having multiple tweens for both closing the door and opening it.

local RootCF = DoorRoot.CFrame

function TweenDoor(Direction)
  TweenService:Create(DoorRoot, DoorSwingInfo, {CFrame = RootCF * CFrame.Angles(0, math.rad(90) * Direction, 0)}):Play()
end

Direction being set to 1 would open the door, 0 close the door, 0.5 open the door half-way etc.

I only posted what was needed to be done.
Thanks anyways!