I'm making a build which requires a lot of spinning objects. Right now, each one has a while true do script which may be causing lag. How would I apply this script to all of the spinning objects instead of having it in each one? All of the spinning objects are in the Workspace and are all called "Propeller"
Here is the script that is in all of them.
while true do script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,-0.2,0) wait(0.001) end
You would have toiterate
through all the objects in workspace, check if they are a part and their name is "Whatever", and then if this applies to any of the parts under workspace, it will rotate them smoothly.
Full Script:
for i, part(game.Workspace:GetChildren()) do if part:IsA("Part") and part.Name == "Namehere" then -- Check if that child is a part, and its name is "Namehere", edit Namehere to whatever the name of the parts are. part.CFrame = part.CFrame * CFrame.fromEulerAnglesXYZ(0,-0.2,0) wait() end end
Note: You cannot have a wait(0.001), the least wait you can have in server script is wait(1/30), if you write anything lower than that, it will default to wait(1/30), wait() without any number in the parameters, also defaults to wait(1/30).
Hope it helps!