My game contains a lot of moving parts (mostly decoration), causing lag in most people who play it. If I could find a way to find what quality level a player is set at, I could reduce the amount of these moving pieces accordingly. Like,
if player.qualitycontrol < 5 then movingpartsspawned = 10 end
Is this possible? If not, any other suggestions to reduce lag in a game?
There is! You can find the users initial quality level by calling the function UserSettings()
and checking the value of it's property GameSettings
's property SavedQualityLevel
.
UserSettings().GameSettings.SavedQualityLevel.Value
However, you will have to keep track of changes to the quality level on your own. You can conveniently do this with an event of DataModel
.
local CurrentGraphicsQualityLevel = UserSettings().GameSettings.SavedQualityLevel.Value game.GraphicsQualityChangeRequest:connect(function(graphicsIncrease) local amount = graphicsIncrease and 1 or -1 local level = CurrentGraphicsQualityLevel + amount if level > 10 then level = 10 elseif level < 1 then level = 1 end CurrentGraphicsQualityLevel = level end)