Door CFrame not working

I’m trying to make a door system for my game… i used TweenService to try to make it work, but it didn’t… only the PrimaryPart (the Hinge) rotates - I used a Highlight to verify.

Any help is appreciated!

The script
local opened = false
local OpenSound = script.Parent.Parent.door_open
local CloseSound = script.Parent.Parent.door_close
local door = script.Parent.Door

function Open()
	if opened == false then
		opened = true
		door.CanCollide = false
		OpenSound:Play()
		game:GetService("TweenService"):Create(script.Parent.PrimaryPart, TweenInfo.new(.5,Enum.EasingStyle.Bounce, Enum.EasingDirection.Out),{CFrame = script.Parent.PrimaryPart.CFrame*CFrame.Angles(0, math.rad(-96), 0)}):Play()

	else
		opened = false
		CloseSound:Play()
		game:GetService("TweenService"):Create(script.Parent.PrimaryPart, TweenInfo.new(.5,Enum.EasingStyle.Bounce, Enum.EasingDirection.Out),{CFrame = script.Parent.PrimaryPart.CFrame*CFrame.Angles(0, math.rad(-96), 0)}):Play()
		door.CanCollide = true
	end
end

script.Parent.Door.ProximityPrompt.Triggered:Connect(Open)

(I kinda think the script is a little unorganised)

You cant tween the whole model by just tweening the primary part. There are 2 simple ways. Either weld everything inside the model and then tween the primary part or tween a cframe value and change the cframe according to it per frame. There is also a post referencing the solution:

1 Like

If it helps, I can post a place file with a tweening door that uses doors with multiple plarts.
So you can actually look it over in studio

1 Like

That would help me alot! Thanks!

1 Like

AutomaticRotatingDoor.rbxl (45.9 KB)
I am not good at explaining things, thats why I like visual examples.
So, here is the file


The Red area is the hitbox for the trigger to open the doors,
The Small Blue area is where sounds are played from

This used to be a ‘sliding’ door example, but I modified it to rotate, using you code, you can see what I changed in code here
image


local openLeft = leftDoor.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(-96), 0)
local openRight = rightDoor.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(96), 0)
--local openLeft = leftDoor.PrimaryPart.CFrame + (leftDoor.PrimaryPart.CFrame.RightVector * -openDistance)
--local openRight = rightDoor.PrimaryPart.CFrame + (rightDoor.PrimaryPart.CFrame.RightVector * openDistance)

I also had to change what was the ‘primary part’ of each door to go from sliding to rotating, when doing this I had to make sure the new primary part was anchored, and that the old one was un-anchored.

So that might be your problem with yours, you can only have the primary part anchored, or at least thats how it works for me.

Hope it helps

2 Likes

My PrimaryPart is the only thing anchored, but even with the model, I dont seem to find how to make the weld contrainst work… (also, sorry for late response)

You select a part…
image

Then under the Model Tab…
image
You select Create - Weld


Then you move the mouse (moving the little red line) to the part you want to weld to
and left click
image
That will weld the parts
image
image
image

1 Like

Thank you very much for the help!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.