Here is my code
function GetPlayerOutfits(userid)
local ProxyUrl = "https://avatar.roproxy.com/v1/users/%d/outfits?page=%d"
local Outfits = {}
for PageNumber = 1, 2 do
task.wait(10)
local RequestUrl = string.format(ProxyUrl, userid, PageNumber)
local Success, Result = pcall(game:GetService("HttpService").GetAsync, game:GetService("HttpService"), RequestUrl)
if Success then
if Result then
local success2, result2 = pcall(game:GetService("HttpService").JSONDecode, game:GetService("HttpService"), Result)
if success2 then
if result2 then
for _, outfitItem in ipairs(result2.data) do
if not outfitItem["isEditable"] then continue end
task.wait(0.1)
table.insert(Outfits, outfitItem.id)
end
end
else
warn(result2)
end
end
else
warn(Result)
end
end
return Outfits
end
local PlayerOutfits
local event = game.ReplicatedStorage.LoadAvatars
event.OnServerEvent:Connect(function(plr, id)
if plr.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("confirm") then
print("tuire")
end
plr.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("confirm").Visible = false
plr.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("open").Visible = false
task.wait(1)
if game.Workspace.Avatars:FindFirstChild("Dummy") then
for i, v in pairs(game.Workspace.Avatars:GetChildren()) do
v:Destroy()
end
PlayerOutfits = GetPlayerOutfits(id)
local pos = 0
for i, outfit in pairs(PlayerOutfits) do
print(i)
local newDummy = game.ReplicatedStorage.Dummy:Clone()
newDummy.Parent = game.Workspace.Avatars
newDummy:PivotTo(newDummy.PrimaryPart.CFrame + Vector3.new(pos, 0, 0))
pos +=10
newDummy.Humanoid:ApplyDescription(game:GetService("Players"):GetHumanoidDescriptionFromOutfitId(1))
task.wait(0.5)
newDummy.Humanoid:ApplyDescription(game:GetService("Players"):GetHumanoidDescriptionFromOutfitId(PlayerOutfits[i]))
end
plr.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("confirm").Visible = true
plr.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("open").Visible = true
else
task.wait(0.1)
PlayerOutfits = GetPlayerOutfits(id)
local pos = 0
for i, outfit in pairs(PlayerOutfits) do
print(i)
local newDummy = game.ReplicatedStorage.Dummy:Clone()
newDummy.Parent = game.Workspace.Avatars
newDummy:PivotTo(newDummy.PrimaryPart.CFrame + Vector3.new(pos, 0, 0))
pos +=10
newDummy.Humanoid:ApplyDescription(game:GetService("Players"):GetHumanoidDescriptionFromOutfitId(1))
task.wait(0.5)
newDummy.Humanoid:ApplyDescription(game:GetService("Players"):GetHumanoidDescriptionFromOutfitId(PlayerOutfits[i]))
end
plr.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("confirm").Visible = true
plr.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("open").Visible = true
end
end)
if the player has too many avatars i get the error saying there are too many requests, increasing the wait timer does not fix it