local AvatarEditorService = game:GetService(“AvatarEditorService”)
local Players = game:GetService(“Players”)
Players.LocalPlayer.CharacterAdded:Connect(function(char)
local player = Players.LocalPlayer
local groupId = 33849291
local groupRank = player:GetRankInGroup(groupId)
– Check if the player’s rank is below 252 or if they are not in the group (rank 0)
if groupRank == 0 or groupRank < 252 then
AvatarEditorService:PromptSetFavorite(122770933559379, Enum.AvatarItemType.Asset, true)
end
end)
I don’t really know the services you are using but i think that you don’t need to wait for CharacterAdded, or if you want your script to be ran everytime the player respawn then put it into StarterPack ?
Seeing your script, you don’t need to optimize it, since there is no memory leak, the only “necessary” or “conventional” thing you could do is setting the groupId outside of the event, since you don’t need to redefine it later.
You could just reorganize it a bit better, other than that, there’s not much you can do.
local AvatarEditorService = game:GetService("AvatarEditorService")
local PlayerService = game:GetService("Players")
local Player = PlayerService.LocalPlayer
Player.CharacterAdded:Connect(function()
if Player:GetRankInGroup(33849291) < 252 then
AvatarEditorService:PromptSetFavorite(122770933559379, Enum.AvatarItemType.Asset, true)
end
end)