Hello, i need some help in creating a CFrame door, when the door rotate just like irl.
Thank you if you could help.
If you wanted to use CFrame to rotate the door, the simplest way is by using SetPrimaryPartCFrame to rotate the door relative to a part in the door that acts as a hinge.
To do this, you would make the door into a model that consists of the door part and a part that is located towards the side of the door at the location you wanted to rotate it relative to.
For this example, the door part would be called Door and the part that will act as the hinge would be called Hinge. This script would go inside the door model and activate when the door is clicked.
local sp = script.Parent sp.PrimaryPart = sp.Hinge local debounce = true local open = false local speed = 1 local cd = Instance.new("ClickDetector") cd.Parent = sp.Door cd.MouseClick:Connect(function(hit) if debounce then debounce = false if open then open = false for i = 1,90/speed do sp:SetPrimaryPartCFrame(sp.PrimaryPart.CFrame * CFrame.Angles(0,math.rad(1*speed),0) wait() end else open = true for i = 1,90/speed do sp:SetPrimaryPartCFrame(sp.PrimaryPart.CFrame * CFrame.Angles(0,math.rad(-1*speed),0) wait() end end debounce = true end end)