I wanted to make a coin system, where every part in a folder would rotate.
I don’t want to add a script to every coin, as that would be laggy, with all the coins I plan to add.
The only part that’s moving is the first item in the folder.
I looked for related topics but I couldn’t find any. Does anybody know a way to bypass this?
The reason is it not working is because you are calling the while true loop while the for loop is still running. Because of this, when the for loop ends, the while true will as well. To fix this, I have simply placed the for loop outside of the while loop, in its own function, and I call it when I want it to rotate.
local function RotateCoins(ContentFolder: Folder)
for _, Coinpart in pairs(ContentFolder:GetChildren()) do
if Coinpart:IsA("BasePart") then
Coinpart.Orientation += Vector3.new(0, 5, 0)
end
end
end
while task.wait(0.05) do -- // Change the time to your likings
RotateCoins(script.Parent)
end