You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? rotating coins smoothly with cframe.
**What is the issue? ** so the issue is that I want to make my coins rotate smoothly but since I have thousands of coins in my game I don’t want to create that much scripts and use that much while loop.
What solutions have you tried so far? I can’t come up with an idea.
local coins = workspace.Coins:GetChildren() -- put the coins in a model called "Coins" in Workspace
while true do
for _,coin in next, coins do
coin.CFrame *= CFrame.Angles(0, math.rad(0.2), 0)
end
game:GetService("RunService").Heartbeat:Wait()
end
I use tweening a lot but I wouldn’t use it for things like that because you can control CFrame animations better, and calling TweenService always puts slightly more load on the server. I’m not saying Tweening is bad, but you don’t always need it for simple things like that. For value tweening, TweenService is a lot more practical, though.
Yea I was thinking of using for loops but I was not 2 sure that it was going to work since it had to rotate 1coin then go to 2nd but now I am assuming that it happens instantly .
Edit:btw is “next” same as pairs? Or os it something new??
Next is very similar, and ultimately it’s not a huge deal which you use. Next loops through the table until a value is nil, and when you’re using :GetChildren(), there’s really no difference. However, I think next goes through the table one at a time, which could be less laggy, but don’t quote me on that. For your purpose, it really doesn’t matter.
Just a heads up that is not true about ‘next’; “next”, “pairs”, and “ipairs” in lua behave and are the same (but ipairs only returning 3 index’s and its values)
You can perform a clamped pairs using the following code: