Optimize lag from looped moving parts

never set up a table before and from what I read I think I have this right? but no errors in output and it not working correctly, is the (6) suppose to be the number of parts I’m trying to move? or did I just set this table completely wrong.

local laser = game.Workspace.ObbyStructure.towerofhell.red.lazer

local Table={"laser" , 6 , true , game.Workspace.ObbyStructure.towerofhell.red.lazer}
for i=1, #Table do 
   laser.CFrame = laser.CFrame * CFrame.Angles(0, 0.04, 0) wait(0.02)
end

I don’t know how you put your parts in the explorer but, assuming they are children of workspace.ObbyStructure.towerofhell.red, this code should work:

local lasers = workspace.ObbyStructure.towerofhell.red:GetChildren()

while true do
	for i, child in pairs(lasers) do
		if child:IsA("BasePart") then
			child.CFrame = child.CFrame * CFrame.Angles(0, 0.04, 0)
		end
	end
	wait(0.02)
end

This script will get the children of workspace.ObbyStructure.towerofhell.red, and rotate all it’s baseparts continuosly.

2 Likes

worked! had to group some parts like the floor cause they started moving as well :laughing: but after only the lasers started spinning! thanks

1 Like