Trying to rotate parts with In pairs loop

I made a script where alarms would go off and make that zone go into lockdown but the only thing that is not working is things not rotating.

local alarms = {}
for i,v in pairs(workspace.AlarmS1:GetDescendants()) do
	if v:IsA('PointLight') or v:IsA('SurfaceLight') or v:IsA('SpotLight') then
		table.insert(alarms,v)
	end
end
for i,v in pairs(alarms) do
	Bool.Changed:Connect(function()
		if Bool.Value == true then
			while true do
				wait(2)
				print("Yes")
				v.Parent.Orientation = v.Parent.Orientation + Vector3.new(1, 0, 0)
			end
		end
	end)
end

image
image

Theories:

I am thinking that the script is working fine but the problem is it is causing enough lag to the server that it makes it take time to rotate. Even if it was this problem, I don’t know what would be the method to make it not lag with the for.

try to use CFrame.Angles instead

v.Parent.CFrame = CFrame.new(v.Parent.Position) * CFrame.Angles(1,0,0)
1 Like

It didnt work.

  19:55:32.834  Workspace.LockdownS1L.Level.ClickDetector.s1script:112: invalid argument #1 to 'new' (Vector3 expected, got CFrame)  -  Servidor - s1script:112

Yeah, my theorie confirms it, it causing lag so the parts isnt rotating

i fixed the code did you try again?

Let me see


image
Now they are like this

image