You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? I want to be able to load more than just 2 people
-
What is the issue? I have an outfit loader but if 2 (Sometimes 1) load request(s) are made it stops working after second one, I get the following error codes: error code 429 (To many requests), Error code 400 (Bad Request and error code 500 (Internal server error)
-
What solutions have you tried so far? Ive looked on other dev forum posts but none of them can help me, Ive tried searching up possible ways to fix it but still couldnt find anything.
local httpService = game:GetService("HttpService")
local baseUrl1 = "https://avatar.roproxy.com/v1/users/"
local baseUrl2 = "/outfits?itemsPerPage=50"
local requests = {}
local Players = game:GetService("Players")
local GuiPart = workspace.GuiPart
local Frame = GuiPart.SurfaceGui.Frame
local PlayerNameText = Frame.BottomFrame.PlayerName
local PlayerIconImage = Frame.MiddleFrame.PlayerIcon
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local QueuePart = workspace.QueuePart
local QueueScroll = QueuePart.SurfaceGui.Frame.ScrollingFrame
local QueueTemplate = script.Template
local CurrentRequested
local checkPlayer = function()
if #requests >= 1 then
local userId = (requests[1])
local data = httpService:JSONDecode(httpService:GetAsync(baseUrl1..userId..baseUrl2))
if data then
CurrentRequested = userId
local name
pcall(function ()
name = Players:GetNameFromUserIdAsync(userId)
end)
local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
PlayerNameText.Text = name
PlayerIconImage.Image = content
game.Workspace.Map.Outfits:ClearAllChildren()
local outfits = data.data
for i, v in pairs(outfits) do
local desc = game.Players:GetHumanoidDescriptionFromOutfitId(v.id)
local c = game.ServerStorage.BaseAvatar:Clone()
c.Name = v.name
c.Parent = workspace.Map.Outfits
c.HumanoidRootPart.Position = Vector3.new(workspace.StartingPoint.Position.X + (5 * (#workspace.Map.Outfits:GetChildren() - 1)), workspace.StartingPoint.Position.Y + 2.5, workspace.StartingPoint.Position.Z)
c.Humanoid.NameDisplayDistance = 50
c.Humanoid:ApplyDescription(desc)
c.HitBox.Position = c.HumanoidRootPart.Position
end
table.remove(requests, table.find(requests, userId))
QueueScroll:FindFirstChild("1"):Destroy()
local Items = 0
for _, Child in ipairs(QueueScroll:GetChildren()) do
if Child:IsA("Frame") then
Items += 1
end
end
for i = 1, Items do
for _, Child in ipairs(QueueScroll:GetChildren()) do
if Child:IsA("Frame") then
Child.Name = 1
end
end
end
end
end
end
local loop = function()
while task.wait(60) do
if #requests >= 1 then
checkPlayer()
else
repeat game:GetService("RunService").Heartbeat:Wait() until #requests >= 1
end
end
end
game.ReplicatedStorage.RequestUser.OnServerInvoke = function(plr, targetName)
local targetUserId = game.Players:GetUserIdFromNameAsync(targetName)
if targetUserId ~= nil then
local isOnRequests = false
for i, v in pairs(requests) do
if v == targetUserId then
isOnRequests = true
break
end
end
if isOnRequests == false then
if not table.find(requests, targetUserId) then
table.insert(requests, targetUserId)
QueueScroll:ClearAllChildren()
local LayoutClone = script.UIListLayout:Clone()
LayoutClone.Parent = QueueScroll
local DidAlready = {}
for i = 1, #requests do
print(#requests)
print(i)
if not table.find(DidAlready, requests[i]) then
table.insert(DidAlready, requests[i])
local PlayerThumbnail = Players:GetUserThumbnailAsync(requests[i], Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
local PlayerInfo = Players:GetNameFromUserIdAsync(requests[i])
local NewTemplate = QueueTemplate:Clone()
NewTemplate.Name = i
NewTemplate.LayoutOrder = i
NewTemplate.MainFrame.TextLabel.Text = PlayerInfo
NewTemplate.PlayerIcon.Image = PlayerThumbnail
NewTemplate.Visible = true
NewTemplate.Parent = QueueScroll
end
end
end
if #requests == 1 then
checkPlayer()
end
return "Queued"
else
return "Already Listed"
end
else
return "Doesn't Exist"
end
end
coroutine.wrap(loop)()