Im trying to call a function but it isnt working. Here is the code
local httpService = game:GetService("HttpService")
local baseUrl1 = "https://avatar.roblox.com/v1/users/"
local baseUrl2 = "/outfits?itemsPerPage=50"
local requests = {}
local proxyHttp = require(game.ServerScriptService.ProxyRobloxAPI:Clone())
local v
local targetUserId
local isRunning = true
local currentid
local function checkPlayer()
print("1")
if #requests == 1 then
print("2")
isRunning = true
local userId = (requests[1])
local s, x = pcall(function()
local data = proxyHttp:GetAsync(baseUrl1..userId..baseUrl2) -- https://avatar.roblox.com/v1/users/2046139136/outfits?itemsPerPage=50
if data then
print("3")
print("cleared")
game.Workspace.Map.Outfits:ClearAllChildren()
local outfits = data.data
for i, v in pairs(outfits) do
currentid = requests[1]
local desc = game.Players:GetHumanoidDescriptionFromOutfitId(v.id)
local thumb = game.Players:GetUserThumbnailAsync(targetUserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
print(thumb)
workspace.UserImage.SurfaceGui.ImageLabel.Image = thumb
local c = game.ServerStorage.BaseAvatar:Clone()
c.Name = v.name
c.Parent = workspace.Map.Outfits
c.HumanoidRootPart.Position = Vector3.new(-123 + (5 * (#workspace.Map.Outfits:GetChildren() - 1)), -5, -59.5)
c.Humanoid.NameDisplayDistance = 50
c.Humanoid:ApplyDescription(desc)
c.HitBox.Position = c.HumanoidRootPart.Position
end
end
end)
end
table.remove(requests, table.find(requests, currentid))
print("table removed")
isRunning = false
end
game.ReplicatedStorage.RequestUser.OnServerInvoke = function(plr, targetName) -----FIRST THING IN THIS SCRIPT TO HAPPEN
local s, x = pcall(function()
targetUserId = game.Players:GetUserIdFromNameAsync(targetName) --get name
table.insert(requests, targetUserId)
if #requests >= 1 then
checkPlayer()
print("Put in queue")
end
end)
if not s and x then warn(x) end
end
--coroutine.wrap(loop)()
while true do
wait(3)
print(#requests)
end
I get an output of “Put in queue” but the function doesnt seem to run.