How can I correctly rotate a door

Ok so,
I’m making a door (toilet cuz why not) and I’d like that when the player click “e”, the door rotate and allow the player to, or get access to the interior. Here is what does it do :
https://cdn.discordapp.com/attachments/772195457673461782/821328696425840640/Map_-_Roblox_Studio_2021-03-16_11-26-10.mp4
Here is the code :

local door = script.Parent.Parent
local rf = script.Parent.Parent.Parent.RotateFIxer
local pr = script.Parent
TweenService = game:GetService("TweenService")
spininfo = TweenInfo.new(2,Enum.EasingStyle.Linear)
Spin1 = TweenService:Create(door,spininfo,{CFrame = door.CFrame * CFrame.Angles(math.rad(120),0,0)})
Spin2 = TweenService:Create(rf,spininfo,{CFrame = rf.CFrame * CFrame.Angles(math.rad(120),0,0)})
pr.Triggered:Connect(function()
	door.Anchored = true
	Spin1:Play()
	Spin2:Play()
end)
1 Like

Ignore the fact that I forgot to put a - to make it rotate on the other side

1 Like

Put a part where the door hinge would normally be (make it transparent if you want) and make the hinge the primary part of the model. Rotating the model will then rotate from the hinge

1 Like

I tried ! It’s the RotateFixer part
But the problem is that when I union it, it make the door invinsible too

1 Like

Don’t union it then. Just group all the separate parts into a model (ctrl+g), set the hinge as primary part and rotate the model

I don’t understand what your saying

1 Like

Select all the parts that make up your door and group them (using ctrl+g to group), this will group all the pieces into a modelpart:
–Model
------MainDoorPart
------HingePart
------HandlePart

etc etc
then set the primary part of the ModelPart to HingePart. Now when you rotate the ModelPart CFrame it will rotate from the hinge not the centre of the door as in your video

I don’t have hinge part, just Door (Union) and a copy of the door, placed at its opposite, invisible and CanCollide false

1 Like

obraz
I made two parts and connect them with “WeldConstraint”. I named the green part “a”.
obraz

local hinge = game.Workspace.a
local pr = script.Parent
hinge.Anchored = true
TweenService = game:GetService("TweenService")
spininfo = TweenInfo.new(1,Enum.EasingStyle.Linear)
Spin1 = TweenService:Create(hinge, spininfo,{CFrame = hinge.CFrame * CFrame.Angles(0, math.rad(-90),0)})
Spin2 = TweenService:Create(hinge, spininfo,{CFrame = hinge.CFrame * CFrame.Angles(0, math.rad(0),0)})

local open = true
pr.Triggered:Connect(function()
	if open == true then
		Spin1:Play()
		open = false
	else
		Spin2:Play()
		open = true
	end
end)

3 Likes

You can create a separate part to use as the hinge, the door doesn’t need to be just one part, it can be made up of several parts and grouped into a model

1 Like

Added an HingeConstrait.
Then I put this as primary part and this is it?

Not a HingeConstraint, just a regular Part, just called it Hinge to highlight it’s function.

If i do that, the proximity prompt thing doesn’t work anymore

1 Like

Place the proximity prompt inside the Model too

1 Like