Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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. ;)

4 comments

0

+1 for recommending scriptguider

0

Yeah, I can explain it but I am dedicating some of my time. If there's any questions I can definitely help.

0

Alright Ill try that out, thanks hopefully it works out.

0

Thanks so much man that helped out alot I was stuck on that for awhile

This discussion is preserved as it was. New answers, comments, and votes are closed.