How to make multiple parts rotate with 1 script

Hello, i’m trying to make multiple parts rotate by using one script and it only rotates one of the parts.
any help is appreciated
script:

for i, part in pairs(game.Workspace:GetChildren()) do
	if part.Name == "rotate" then
		local number = 0
		while true do
			part.Rotation = Vector3.new( 0, number, 0) 
			wait(0.01) 
			number = number+3 
		end
	end
end

oh thanks but tbh i don’t know much about tweening parts

Here’s a basic example of how you would use a tween:

-- Variables
local PartToTween = YourPart
local DesiredOrientation = Vector3.new(0,180,0)
local TweenLength = 1
local TweenService = game:GetService("TweenService")
-- You can google EasingStyle & EasingDirection for more information
local Info = TweenInfo.new(TweenLength,Enum.EasingStyle.Linear,Enum.EasingDirection.Out)
-- Set what action you would like to perform
local Goals = {Orientation = DesiredOrientation}
-- Create the tween itself
local Tween = TweenService:Create(PartToTween,Info,Goals)
Tween:Play()

-- Note: Tweens are best played on the client for smoothness

There’s also video tutorials on youtube if you would like something more in-depth.

1 Like
local Time = 1 --Put any numbers you want, this will be the time everytime the parts spin.

local TweenService = game:GetService("TweenService")
local Parts = workspace.Parts:GetChildren() --Make sure to create a folder that's named "Parts" on the workspace, and also put the parts you want to spin.
local TInfo = TweenInfo.new(Time, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, false, 0)
local Tween = TweenService:Create(Parts, TInfo, {Orientation = Vector3.new(0,360,0}

Tween:Play()

More informations about Tweening.

2 Likes