Bylocks
(Bylocks)
December 14, 2018, 10:35pm
#1
while wait(.04) do
script.Parent.CFrame = script.Parent.CFrame*CFrame.Angles(0, 0, 0.1)
end
I’m rotating a part 360. There could be up to 200 of these parts in the game. I wouldn’t have 200 scripts of this of course I would do something like :GetChildren(). How much would this take a toll on game quality?
Is it a case by case question?
OverHash
(OverHash)
December 14, 2018, 10:41pm
#2
Currently in my game i have about ~20 objects that are rotating all the time for aesthetical purposes. I am doing this by adding functions with bindtorenderstep that rotate the cframe in a localscript. However when I do this for multiple parts the scripts start to lag. What is a good alternative?
I would run this code on the client, to reduce the server load and run it with BindToRenderStepped so that it will be smooth no matter the FPS.
The least resource intensive answer would be to make an animation if it spinning, but with 200 objects that doesn’t sound realistic.
2 Likes
It’ll be laggy just by virtue of the fact you’re doing while wait(n) do
, especially if that’s on the server.
Instead, just use RenderStepped and loop over all the matching parts (perhaps with CollectionService:GetTagged).
1 Like