Spinpart not working?

I am trying to make all the parts called “SpinPart” spin, although my script doesn’t work. Is there anything I did wrong?

local partspeed = 0.05 

for i,v in pairs(game.Workspace:GetChildren()) do
	if v.Name == "SpinPart" then
		v.CFrame = v.CFrame * CFrame.Angles(0,partspeed,0) 
	end
end

tysm for your time!

Your script only rotates the CFrame once, you have to loop it.

local partspeed = 0.05 

for i,v in pairs(game.Workspace:GetChildren()) do
	if v.Name == "SpinPart" then
           spawn(function() -- makes the loop dont break others
                while wait() do
		   v.CFrame = v.CFrame * CFrame.Angles(0,partspeed,0) 
               end
            end)
	end
end

Have you tried encasing it in a loop?

local partspeed = 0.05 

while true do
    for i,v in pairs(game.Workspace:GetChildren()) do
	    if v.Name == "SpinPart" then
		    v.CFrame = v.CFrame * CFrame.Angles(0,partspeed,0) 
	    end
    end
    wait()
end

You could also put all the parts named “SpinParts” inside a folder, and get the children of them that way instead for less script performance

(Ok where did you all come from)

Try this

local partspeed = 0.05
local RunService = game:GetService("RunService")

while true do
    for i,v in pairs(game.Workspace:GetChildren()) do
	     if v.Name == "SpinPart" then
		     v.CFrame *= CFrame.Angles(0,partspeed,0) 
	     end
    end
     RunService.Heartbeat:Wait()
end

Tysm everyone, I can’t believe i didnt notice that!