- What do you want to achieve? Keep it simple and clear!
- I want to efficiently rotate 60 parts in my game to ensure minimal impact on FPS (frames per second).
- What is the issue? Include screenshots / videos if possible!
- I’m unsure which method to use for rotating the parts. The methods I have tried are causing performance issues, and I’m looking for the most FPS-efficient solution.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
- I’ve experimented with two methods:
- Using TweenService to create a rotation tween for each part.
- Using the
RunService.Steppedevent to manually update the CFrame of each part every frame.
Below are the code snippets for the methods I have tried:
-- Method 1: Using TweenService
local TweenService = game:GetService("TweenService")
local CoinRotationTweenInfo = TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, true)
local tweens = {}
for _, part in pairs(parts) do
local tempTween = TweenService:Create(part, CoinRotationTweenInfo, {CFrame = part.CFrame * CFrame.Angles(0, math.rad(120), 0)})
table.insert(tweens, tempTween)
tempTween:Play()
end
-- Method 2: Using RunService.Stepped
game:GetService("RunService").Stepped:Connect(function()
for _, part in pairs(parts) do
part.CFrame = CFrame.new(part.Position) * CFrame.Angles(0, math.rad(part.Orientation.Y - 1), math.rad(90))
end
end)
I would appreciate some guidance on which method is more FPS-efficient. If these methods aren’t optimal, any alternative suggestions would be really, really helpful!
Thank you in advance for your time and help!