Attempt to call missing method 'GetAsync' of table

Hello,
I am making a Outfit Loader game and I keep on getting this error:

This is my script:

-- SERVICES
local players = game:GetService("Players")
local rs = game:GetService("ReplicatedStorage")
local ss = game:GetService("ServerStorage")
local http = require(game.ServerStorage.HTTP)
local dss = game:GetService("DataStoreService")
local ins = game:GetService("InsertService")
local mps = game:GetService("MarketplaceService")

-- VARIABLES
local ds = dss:GetOrderedDataStore("TopPlayers")
local event = rs:WaitForChild("HandlerRemote")
local outfit_folder = workspace.PlayerOutfits
local baseChar = ss.BlockRig
local lobby = workspace.Lobby
local spawns = lobby.SpawnPoints
local display = lobby.Display.PlayerDisplay.Main_Frame
local leaderboard = lobby.TopSearched.TopPlayerDisplay.Main_Frame

-- VALUES
local checking = false
local max_points = 144
local innitial = 210
local display_time = 15
local fit_dist = 5
local currentSlot = 0
local maxTopPlayers = 30
local maxActivationDist = 7

-- TABLES
local queue = {}
local trying = {}

-- FUNCTIONS
local function set_canvas(parent : ScrollingFrame)
	local n = #(parent:GetChildren())
	parent.CanvasSize = UDim2.new(0,0,0,n*innitial)
end

local function create_Clickers(outfit)
	local click = Instance.new("ClickDetector")
	click.Name = "OutfitTrial_Clicker"
	click.Parent = outfit
	click.MaxActivationDistance = maxActivationDist
	
	click.MouseClick:Connect(function(plr)
		local hum : Humanoid = plr.Character:WaitForChild("Humanoid")
		local desc : HumanoidDescription = outfit:WaitForChild("Humanoid"):GetAppliedDescription()
		hum:ApplyDescription(desc)
	end)
end

local function get_clicks()
	for i,v in ipairs(outfit_folder:GetChildren()) do
		local clicker : ClickDetector = v:FindFirstChild("OutfitTrial_Clicker")
		if clicker then
			clicker.MouseClick:Connect(function(plr)
				local hum : Humanoid = plr.Character:WaitForChild("Humanoid")
				local desc : HumanoidDescription = v:WaitForChild("Humanoid"):GetAppliedDescription()
				hum:ApplyDescription(desc)
			end)

		else
			warn("CLK NF: "..v.Name)
		end
	end
end

local function get_slot()
	currentSlot += 1
	if currentSlot > max_points then
		return nil
	end

	local slot = spawns["Part"..currentSlot]
	return slot.CFrame
end

local function make_prompts(dummy)
	local c,p = Instance.new("ClickDetector"), Instance.new("ProximityPrompt")
	c.MaxActivationDistance = maxActivationDist
	p.MaxActivationDistance = maxActivationDist
	c.Parent = dummy
	p.Parent = dummy
 
	c.MouseClick:Connect(function(plr)
		event:FireClient(plr, "LoadChar", dummy)
	end)
	p.Triggered:Connect(function(plr)
		event:FireClient(plr, "LoadChar", dummy)
	end)
end

local function load_outfit(hd, name)
	local new = baseChar:Clone()
	local anime = script:WaitForChild("Animate"):Clone()
	local hum = new:WaitForChild("Humanoid")

	anime.Parent = new
	new.Parent = outfit_folder
	new.Name = name
	hum.DisplayName = name
	--create_Clickers(new) -- For the Asset Menu
	make_prompts(new) -- For the new Try and Buy Asset Menu
	
	local cf = get_slot()
	if cf then
		new:SetPrimaryPartCFrame(cf)
		hum:ApplyDescription(hd)
	else
		warn("Slots full")
	end
end

local function remove_frame(id)
	local frame = display.Queue:FindFirstChild("-/\-"..id)
	if frame then
		frame:Destroy()
	end
end

local function add_queue_frame(name, id)
	local frame = rs.Storage.QueueFrame:Clone()
	frame.Name = "-/\-"..id
	frame.FrameOfName.PlayerName.Text = name
	pcall(function()
		frame.Thumbnail.Image = players:GetUserThumbnailAsync(id, Enum.ThumbnailType.AvatarBust, Enum.ThumbnailSize.Size420x420)
	end)
	frame.Parent = display.Queue
	set_canvas(display.Queue)
end

local function addTo_queue(name, from_plr : Player?)
	local id
	pcall(function()
		id = players:GetUserIdFromNameAsync(tostring(name)) or nil
	end)
	if id then
		if not table.find(queue, id) then
			table.insert(queue, id)
			add_queue_frame(name, id)
			
			if from_plr then
				event:FireClient(from_plr, "AddedToQueue", name)
			end

			local s,e = pcall(function()
				local data = ds:GetAsync(id)
				if data then
					data+=1
					ds:SetAsync(id, data)
				else
					ds:SetAsync(id, 1)
				end
			end)
			if not s then warn(e) end
		else
			print("Player already in queue")
			if from_plr then
				event:FireClient(from_plr, "AlreadyInQueue")
			else
				print("From_Plr : NF")
			end
		end
	else
		warn("PDE: "..name)
	end
end

local function add_top_frame(name, id, count, order)
	local frame = rs.Storage.TopPlayerFrame:Clone()
	frame.FrameOfName.PlayerName.Text = name
	frame.FrameOfName.Count.Text = "Count: "..count
	frame.LayoutOrder = order
	
	pcall(function()
		frame.Thumbnail.Image = players:GetUserThumbnailAsync(id, Enum.ThumbnailType.AvatarBust, Enum.ThumbnailSize.Size420x420)
	end)
	frame.Parent = leaderboard.Top_Players
	set_canvas(leaderboard.Top_Players)
	
	frame.Button.MouseButton1Click:Connect(function()
		addTo_queue(name)
	end)
end

local function refresh_board()
	for i,v in ipairs(leaderboard.Top_Players:GetChildren()) do
		if v:IsA("Frame") then
			v:Destroy()
		end
	end
	
	local data = ds:GetSortedAsync(false, maxTopPlayers)
	local page = data:GetCurrentPage()

	for rank, savedData in ipairs(page) do
		local id = tonumber(savedData.key)
		if id then
			coroutine.wrap(function()
				local name = players:GetNameFromUserIdAsync(id)
				if name then
					local count = savedData.value
					if count then
						add_top_frame(name, id, count, rank)
					end
				else
					print("Failed to retrieve name for user ID:", id)
				end
			end)()
		else
			print("Invalid id:", savedData.key)
		end
	end
end

local function try_v(plr, id)
	local asset = ins:LoadAsset(tonumber(id))
	local old = nil
	if not trying[plr.UserId] then trying[plr.UserId]={} end

	for i,v in ipairs(asset:GetChildren()) do
		plr.Character.Humanoid:AddAccessory(v)
		table.insert(trying[plr.UserId], v)
	end
end

-- Triggers
event.OnServerEvent:Connect(function(plr : Player, arg, arg2, arg3)
	if arg == "Add_to_Queue" then
		addTo_queue(arg2, plr)
		
	elseif arg=="ApplyDesc" then
		if trying[plr.UserId] then
			for i,v in ipairs(trying[plr.UserId]) do
				v:Destroy()
			end
		end
		arg2.Humanoid:ApplyDescription(arg3)

	elseif arg == "TryIt" then
		try_v(plr, arg2)
	end
end)

coroutine.wrap(function()
	while task.wait(1) do
		for a,fit in ipairs(outfit_folder:GetChildren()) do
			fit:Destroy()
		end
		if #queue==0 then continue end
		
		local id = tonumber(queue[1])
		local s,e = pcall(function()
			display.Thumbnail.Image = players:GetUserThumbnailAsync(id, Enum.ThumbnailType.AvatarBust, Enum.ThumbnailSize.Size420x420)
			load_outfit(players:GetHumanoidDescriptionFromUserId(id), "Current Outfit")
			local fitData = http:JSONDecode(http:GetAsync("https://avatar.roblox.com/v1/users/"..id.."/outfits"))["data"]
			for a,outfit in ipairs(fitData) do
				load_outfit(players:GetHumanoidDescriptionFromOutfitId(outfit["id"]), outfit["name"])
				task.wait(0.5)
			end
		end)
		if not s then print(e) end
		remove_frame(id)
		task.wait(display_time)
		table.remove(queue, 1)
		currentSlot = 0
		display.Thumbnail.Image = ""
	end
end)()

coroutine.wrap(function()
	while true do
		refresh_board()
		task.wait(10)
	end
end)()

Any help is appreciated. Thanks.

Could you outline the erroring line?

1 Like

It might be because of this:

local http = require(game.ServerStorage.HTTP)

If i’m not wrong, it’s supposed to be:

local http = game:GetService("HttpService")
1 Like

That is a special module handled by the OP. No messing with that.

1 Like

The erroring line is:


local fitData = http:JSONDecode(http:GetAsync("https://avatar.roblox.com/v1/users/"..id.."/outfits"))["data"]

The module is a table of content, so http is a table. It doesn’t have that function. maybe try http.GetAsync

1 Like

isn’t that because http in this case is the module instead of the service?

Try using this:

local HttpService = game:GetService("HttpService")

-- ...

local s, e = pcall(function()
    local url = "https://avatar.roblox.com/v1/users/"..id.."/outfits"
    local response = HttpService:GetAsync(url)
    local fitData = HttpService:JSONDecode(response)["data"]
    -- Process fitData as needed
end)

if not s then
    warn("HTTP request failed:", e)
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.