Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

I cannot figure out how I make this door rotate and position properly with CFrames. Any Help?

Asked by 8 months ago
Edited by DeceptiveCaster 8 months ago

Basically I want this door to be able to move properly even with different positions and rotations. For some reason it constantly moves in some random ways I never can fix. Here are some images to help anyone willing to help me out figure this out. Thank you for reading all of this and hopefully I can figure it out and maybe learn something in the end.

before Opening

After opening

local Knob = script.Parent.Knob

local Frame = script.Parent.Frame

local Screen = script.Parent.Screen

local deg = Frame.Orientation.Y

local Open = script.Parent.Open

function OpenDoor()
    Frame.CFrame = CFrame.new(Frame.Position.X + 2.25,Frame.Position.Y,Frame.Position.Z + 2.25)
    Frame.Orientation = Vector3.new(0, deg - 90 , 0)
    Knob.CFrame = CFrame.new(Knob.Position.X - 4,Knob.Position.Y,Knob.Position.Z - 4)
    Knob.Orientation = Vector3.new(0, deg + 90 , 0)
    Screen.CFrame = CFrame.new(Screen.Position.X - 2.1,Screen.Position.Y,Screen.Position.Z - 2.1)
    Screen.Orientation = Vector3.new(0, deg + 90 , 0)
    script.Parent.OpenFX:Play()
end

function CloseDoor()
    Frame.CFrame = CFrame.new(Frame.Position.X - 2.25,Frame.Position.Y,Frame.Position.Z - 2.25)
    Frame.Orientation = Vector3.new(0, deg - 90 , 0)
    Knob.CFrame = CFrame.new(Knob.Position.X - 4,Knob.Position.Y,Knob.Position.Z - 4)
    Knob.Orientation = Vector3.new(0, deg - 90 , 0)
    Screen.CFrame = CFrame.new(Screen.Position.X - 2.1,Screen.Position.Y,Screen.Position.Z - 2.1)
    Screen.Orientation = Vector3.new(0, deg - 90 , 0)
    script.Parent.OpenFX:Play()
end

Open.Changed:Connect(function()
    print("adasadsdasdas")
    if Open.Value == true then
        print("close")
        CloseDoor()
    else
        print("open")
        OpenDoor()
    end
end)


function KnobClicked()
    if Open.Value == false then
        if script.Parent.Broken.Value == false and Open.Value == false then
            print("open")
            Open.Value = true
        end
    elseif script.Parent.Broken.Value == false then
        print("close")
        Open.Value = false
    end
end


Knob.ClickDetector.MouseClick:Connect(KnobClicked)

If you have any questions I perfer using Discord, but I also can tr and check up on here although Im not too active anymore.

1 answer

Log in to vote
2
Answered by 8 months ago

My best recommendation is to follow this video. It describes everything you need to make your door work!

If you have any questions or issues please contact me. ;)

0
+1 for recommending scriptguider programmerHere 370 — 8mo
0
Yeah, I can explain it but I am dedicating some of my time. If there's any questions I can definitely help. lazycoolboy500 537 — 8mo
0
Alright Ill try that out, thanks hopefully it works out. Sergiomontani10 236 — 8mo
0
Thanks so much man that helped out alot I was stuck on that for awhile Sergiomontani10 236 — 8mo
Ad

Answer this question