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

When the doors of my sliding door opens, the orientation changes?

Ok so basically, I scripted a sliding door, and the problem is that I can't get the doors to stay at a constant orientation. The doors open fine and everything except for one thing. When the doors open, they turn sideways and don't face the right way. Here is all of my code I did. I used tweening.

local TweenService = game:GetService("TweenService")
local door1 = script.Parent:WaitForChild("Door1")
local door2 = script.Parent:WaitForChild("Door2")
local tweeningInformation = TweenInfo.new(
	0.5,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)
local door1Open = {CFrame = CFrame.new(6, 18, -157)}
local door2Open = {CFrame = CFrame.new(-81, 17.5, -156.5)}
local door1Close = {CFrame = CFrame.new(-23, 18, -157)}
local door2Close = {CFrame = CFrame.new(-54, 17.5, -156.5)}
local tween1open = TweenService:Create(door1,tweeningInformation,door1Open)
local tween1close = TweenService:Create(door1,tweeningInformation,door1Close)
local tween2open = TweenService:Create(door2,tweeningInformation,door2Open)
local tween2close = TweenService:Create(door2,tweeningInformation,door2Close)

script.Parent.Detector1.Touched:Connect(function(hit)
	tween1open:Play()
	tween2open:Play()
	wait(2)
	tween1close:Play()
	tween2close:Play()
end)
script.Parent.Detector2.Touched:Connect(function(hit)
	tween1open:Play()
	tween2open:Play()
	wait(2)
	tween1close:Play()
	tween2close:Play()
end)

1 answer

✓ Accepted answer

Add this to the script right after it changes the position of the door each time.


while true do wait()
    model:SetPrimaryPartCFrame(model:GetPrimaryPartCFrame() * CFrame.Angles(0, math.rad(45), 0)) -- model is the door. This should rotate it back into frame.
end

Hope this helps you in some way.

3 comments

0

Wow thanks!

0

wait so it helped?

0

thx

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