How to make Part properly rotate 90 degrees with Tween

Hello,

So I’m making a puzzle inspired by the one in the game The Door In The Basement in which where you click on some valves to rotate platforms that you will need to line up in order to reach the other side of a cave. However I can’t get the part that one of my platforms is welded to to move 90 degrees properly. Here’s some footage of what I’m going for:

My current attempt of doing this:

(Don’t mind the green and red parts, those are just me temporarily marking which platforms will be movable and which won’t be)


I tried using an already made script of mine from a portrait that rotates but as you see, it didn’t really help achieve what I’m going for here. I’d like for it to rotate 90 degrees towards the right in the position that it’s originally in. The script also seems to not keep playing after it’s done running. Here’s the setup:

The part that the entire platform’s model is welded to that rotates everything:

Model in Workspace

The code inside the script:

local RotatingPart = game.Workspace.RotatingPart1
local info = TweenInfo.new(0.2,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,false,0)
local alreadyTriggered = false
local Valve = script.Parent
local ValveClickDetector = script.Parent.ClickDetector



Valve.ClickDetector.MouseClick:Connect(function()
if alreadyTriggered == false then
	alreadyTriggered = true

	local goals = {
		CFrame = RotatingPart.CFrame * CFrame.Angles(math.rad(-90),0,0)
	}

		local tween = game:GetService("TweenService"):Create(RotatingPart,info,goals)
		
		ValveClickDetector.MaxActivationDistance = 0
		tween:Play()
		tween.Completed:Wait(0.5)
		ValveClickDetector.MaxActivationDistance = 12
		wait(0.5)
end
end)

I already looked up similar threads to my case but they weren’t of much help. I’d truly appreciate your help on this! This would be a piece of cake to an experienced scripter.

you need to turn it 90 degrees in a different axis

1 Like
local RotatingPart = game.Workspace.RotatingPart1
local info = TweenInfo.new(0.2,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,false,0)
local alreadyTriggered = false
local Valve = script.Parent
local ValveClickDetector = script.Parent.ClickDetector



Valve.ClickDetector.MouseClick:Connect(function()
if alreadyTriggered == false then
	alreadyTriggered = true

	local goals = {
		Orientation = Vector3.new(RotatingPart.Orientation.X - 90, RotatingPart.Orientation.Y, RotatingPart.Orientation.Z)
	}

		local tween = game:GetService("TweenService"):Create(RotatingPart,info,goals)
		
		ValveClickDetector.MaxActivationDistance = 0
		tween:Play()
		tween.Completed:Wait(0.5)
		ValveClickDetector.MaxActivationDistance = 12
		wait(0.5)
end
end)

I changed the goals table and instead of using CFrame, I replaced It with a Vector3.

1 Like

Already tried that but it doesn’t seem to move 90 degrees from the sides like in the first clip shown from the other game. Why could that be?

Thanks, but how would I make it rotate 90 degrees from the sides like in the first clip? Seems to be doing something else.

Never mind about the question, literally just had to put 90 in another axis lol. Thanks!