How do i break this Rotating model loop

how do i break this loop after 4 seconds

local shaking = false
wait(6)
if shaking == false then
	while true do
		wait()
		script.Parent:SetPrimaryPartCFrame(script.Parent.PrimaryPart.CFrame * CFrame.Angles(0.003,0,0))
		if shaking == false then
			wait(4)
			shaking = true
			break
		end
	end
end

please help me.

Why not use a for loop? The purpose of using a while loop is not knowing if you’ll be ending it at a specific time or number. You’re only waiting for 4 seconds so a for loop would probably be better.