Help tweening sliding door

Hello.
I am working on tweening a sliding door when you press it. It all works and all, but it doesn’t allow me to have the model at any other orientation. Here is my code for that:

door.ClickDetector.MouseClick:Connect(function()
	utilityModule:tweenModel(
		door, 
		door:GetPivot() * CFrame.new(door:GetPivot().RightVector * (door.IsOpen.Value and 5 or -5)), 
		TweenInfo.new(
			0.5, 
			Enum.EasingStyle.Linear, 
			(door.IsOpen.Value and Enum.EasingDirection.In or Enum.EasingDirection.Out)
		)
	)

	door.IsOpen.Value = not door.IsOpen.Value
end)

How could I make this work no matter the orientation of the door?

Thanks,
– Ham

1 Like

what you could try is multiplying the door:GetPivot() to a normal vector3, aka Vector3.new(direction, 0, 0). It should fix your issue (And if the Vector3.new is pushing it in the wrong direction, just change either the x, y, z values, basically playing around with the values.)

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