Part rotates back and forth after a while instead of going in one direction

so this annoys me. I wanna rotate a part and it does smoothly until I stop pressing E. After that, if I want to rotate again, it shifts back and forth and doesn’t rotate normally anymore.
vid for reference:

1 Like

Can you provide the code you’re using?

local function onPromptHoldBegan(promptObject, player)
	while true do
		Valve.Orientation = Valve.Orientation + Vector3.new(-10, 0, 0)
		wait(0.5)
	end
end

Any alternative to “While true do”? After I press E, the part moves indefinetly.

I’m currently working on an alternative for Orientation, which is Using CFrame

local function onPromptHoldBegan(promptObject, player)
	while true do
		Valve.CFrame = Valve.CFrame*CFrame.Angles(0.1, 0, 0)
		wait()
	end
end

Now I’m trying to fix the “moving infinitely” part

Add a debounce.

local playerHolding -- debounce

function OnPromptButtonHoldBegan(player)
	if playerHolding then return end -- prevent multiple players from rotating
	playerHolding = player
	repeat
		-- apply rotation
		task.wait(1/30)
	until not playerHolding 
end

function OnPromptButtonHoldEnded(player)
	if playerHolding == player then
		playerHolding = nil
	end
end

Thank you! This worked flawlessly. I’ve marked your answer as a Solution. Have a great day!