ReplicatedStorage.AssetManager:13: attempt to compare nil < number
Stack Begin
Script “ReplicatedStorage.AssetManager”, Line 13
Script “ReplicatedStorage.AssetManager”, Line 11 - function getUserGeneratedTShirtsRescursive
Script “ReplicatedStorage.AssetManager”, Line 84 - function GetAssets
Script “Workspace.Stands.7.Proximity.Attachment.ProximityPrompt.MainScript”, Line 49 - function Triggered
Stack End
Do you mind showing us your script?
1 Like
Asset Manager
local AssetManager = {}
local HttpService = game:GetService("HttpService")
local UrlA = "https://catalog.roproxy.com/v1/search/items/details?Category=3&CreatorName="
local function getUserGeneratedTShirtsRecursive(username, SignPrices, tshirts, cursor)
tshirts = tshirts or {}
local requestUrl = UrlA
local data = HttpService:JSONDecode(HttpService:GetAsync(UrlA .. username)).data
if data then
table.sort(data,
function(a,b)
return a.price < b.price
end
)
for _, item in ipairs(data) do
local e,s = pcall(function()
table.insert(tshirts, item.id)
local newBtn = script.Template:Clone()
local price = item.price
newBtn.PurchaseButton.Text = "$"..price
newBtn.LayoutOrder = price
newBtn.Name = price
newBtn.ImportantValues.AssetId.Value = item.id
newBtn.Parent = SignPrices
end)
end
end
return tshirts
end
local UrlB = "https://www.roproxy.com/users/inventory/list-json?assetTypeId=34&cursor=&itemsPerPage=100&pageNumber=%s&userId=%s"
local function getUserCreatedGamepassesRecursive(userId, SignPrices, gamepasses, pageNumber, lastLength)
gamepasses = {}
pageNumber = pageNumber or 1
lastLength = lastLength or math.huge
local requestUrl = UrlB:format(pageNumber, userId)
local success, result = pcall(function()
return HttpService:GetAsync(requestUrl)
end)
if success then
if result then
local success2, result2 = pcall(function()
return HttpService:JSONDecode(result)
end)
if success2 then
if result2 then
for _, gamepass in ipairs(result2.Data.Items) do
if gamepass.Creator.Id == userId and table.find(gamepasses, gamepass.Item.AssetId) == nil then
table.insert(gamepasses, gamepass.Item.AssetId)
local e,s = pcall(function()
local newBtn = script.Template:Clone()
local price = gamepass.Product.PriceInRobux
newBtn.Name = price
newBtn.PurchaseButton.Text = "$"..price
newBtn.LayoutOrder = price
newBtn.ImportantValues.AssetId.Value = gamepass.Item.AssetId
newBtn.ImportantValues.AssetType.Value = "Gamepass"
newBtn.Parent = SignPrices
end)
end
end
else
warn(result)
getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
end
end
else
warn(result)
getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
end
return gamepasses
end
end
function AssetManager:GetAssets(Player, BoothUI)
getUserGeneratedTShirtsRecursive(Player.Name, BoothUI)
getUserCreatedGamepassesRecursive(Player.UserId, BoothUI)
end
return AssetManager
Main Script
local Prompt = script.Parent
local Owner = script.Parent.Parent.Parent:FindFirstChild("Owner")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EventsFolder = ReplicatedStorage:FindFirstChild("Events")
local Bindable = EventsFolder:FindFirstChild("ClaimPlot")
local Notification = EventsFolder:FindFirstChild("Notification")
local EditPlot = EventsFolder:FindFirstChild("EditPlot")
local MarketPlaceService = game:GetService("MarketplaceService")
local OwnerLabel = script.Parent.Parent.Parent.Parent.SignDescription.SurfaceGui.Frame.OwnerLabel
local StarterGui = game:GetService("StarterGui")
local StandNum = script.Parent.Parent.Parent.Parent.Name
local AssetManager = require(ReplicatedStorage:WaitForChild("AssetManager"))
local SignPrices = script.Parent.Parent.Parent.Parent.SignPrices
function Triggered(Player)
local PlayerName = Player.Name
if Owner.Value == nil or "NoOne" then -- If booth hasn't been claimed
if Player:FindFirstChild("Owner") then -- If Player has claimed one
Notification:FireClient(Player, "You Already Own A Booth!") -- Let them know they already own one
else -- If Player hasn't claimed one
Owner.Value = PlayerName
OwnerLabel.Text = PlayerName .. "'s Stand"
Notification:FireClient(Player, "Successfully Claimed!") -- Claimed
local UserID = game:GetService("Players"):GetUserIdFromNameAsync(PlayerName)
Bindable:Fire(script.Parent.Parent.Parent.Parent.Name, PlayerName, UserID)
local OwnerValue = Instance.new("IntValue")
OwnerValue.Value = script.Parent.Parent.Parent.Parent.Name -- set int value to booth name
OwnerValue.Name = "Owner"
OwnerValue.Parent = Player
-- Would this be the best way to do this? Yes, absolutely!
-- We want the editPrompt to ONLY show for the client player.
EditPlot:FireClient(Player, script.Parent.Parent.Parent.Parent.Name, true)
Prompt.Enabled = false
AssetManager:GetAssets(Player, SignPrices.UI.ScrollingFrame)
-- This should be for giving a player a value
OwnerLabel.Parent.MoneyRaised.Text = Player.leaderstats.Raised.Value .. "$ Raised"
end
end
end
script.Parent.Triggered:Connect(Triggered)
local Players = game:GetService("Players")
Players.PlayerRemoving:Connect(function(player)
local plrRemovingName = player.Name
if plrRemovingName == Owner.Value then
Owner.Value = "NoOne"
EditPlot:FireClient(player, script.Parent.Parent.Parent.Parent.Name, false)
Prompt.Enabled = true
OwnerLabel.Text = "No One's Stand"
script.Parent.Parent.Parent.Parent.SignTitle.SurfaceGui.Frame.SignLabel.Text = "PLS DONATE"
OwnerLabel.Parent.MoneyRaised.Text = "0$ Raised"
script.Parent.Parent.Parent.Parent.NewStand.Value = false
script.Parent.Parent.Parent.Parent.AdminStandVal.Value = false
local Children = SignPrices.UI.ScrollingFrame:GetChildren()
for _, child in ipairs(Children) do
if child:IsA("Frame") and child.Name ~= "Template" then
child:Destroy()
end
end
else
return -- Not the Owner
end
end)
local ChangeTheme = EventsFolder.StandEvents.ChangeTheme
local Booth = script.Parent.Parent.Parent.Parent
ChangeTheme.OnServerEvent:Connect(function(Player, Plr, Theme, Val)
local Booths = workspace.Stands
if Booth.Proximity.Owner.Value == Player.Name and Player.leaderstats.Donated.Value >= Val then
if Theme == "default" then
Booth.NewStand.Value = false
for _, Desc in ipairs(Booth:GetChildren()) do
if Desc.Name == "Primary" then
Desc.Material = Enum.Material.SmoothPlastic
Desc.Color = Color3.fromRGB(188, 155, 93)
elseif Desc.Name == "Secondary" or Desc.Name == "SignDescription" then
Desc.Material = Enum.Material.SmoothPlastic
Desc.Color = Color3.fromRGB(160, 132, 79)
elseif Desc.Name == "Tertiary" or Desc.Name == "SignTitle" or Desc.Name == "SignPrices" then
Desc.Material = Enum.Material.SmoothPlastic
Desc.Color = Color3.fromRGB(211, 190, 150)
end
end
elseif Theme == "onethousand" then
Booth.NewStand.Value = false
for _, Desc in ipairs(Booth:GetChildren()) do
if Desc.Name == "Primary" then
Desc.Material = Enum.Material.SmoothPlastic
Desc.Color = Color3.fromRGB(99, 95, 98)
elseif Desc.Name == "Secondary" or Desc.Name == "SignDescription" then
Desc.Material = Enum.Material.SmoothPlastic
Desc.Color = Color3.fromRGB(67, 64, 66)
elseif Desc.Name == "Tertiary" or Desc.Name == "SignTitle" or Desc.Name == "SignPrices" then
Desc.Material = Enum.Material.SmoothPlastic
Desc.Color = Color3.fromRGB(223, 223, 222)
end
end
elseif Theme == "tenthousand" then
Booth.NewStand.Value = false
for _, Desc in ipairs(Booth:GetChildren()) do
if Desc.Name == "Primary" then
Desc.Material = Enum.Material.Neon
Desc.Color = Color3.fromRGB(99, 95, 98)
elseif Desc.Name == "Secondary" or Desc.Name == "SignDescription" then
Desc.Material = Enum.Material.Neon
Desc.Color = Color3.fromRGB(67, 64, 66)
elseif Desc.Name == "Tertiary" or Desc.Name == "SignTitle" or Desc.Name == "SignPrices" then
Desc.Material = Enum.Material.Neon
Desc.Color = Color3.fromRGB(223, 223, 222)
end
end
elseif Theme == "onehundredthousand" then
Booth.AdminStandVal.Value = false
Booth.NewStand.Value = true
elseif Theme == "admin" then
Booth.NewStand.Value = false
Booth.AdminStandVal.Value = true
end
end
end)
local RefreshEvent = game.ReplicatedStorage.Events:WaitForChild("Refresh")
RefreshEvent.OnServerEvent:Connect(function(Player, Booth)
if Booth == script.Parent.Parent.Parent.Parent.Name then
local Children = SignPrices.UI.ScrollingFrame:GetChildren()
for _, child in ipairs(Children) do
if child:IsA("Frame") and child.Name ~= "Template" then
child:Destroy()
end
end
local UserID = game:GetService("Players"):GetUserIdFromNameAsync(Player.Name)
Bindable:Fire(script.Parent.Parent.Parent.Parent.Name, Player.Name, UserID)
end
end)
Those are the scripts provided in the error message.
Looks like this is the problem. Apparently a.price doesn’t exist.
1 Like
Wait do b.price exist, or?
Is this all correct:
if data then
table.sort(data, function(a,b)
return a.price < b.price
end
)
Yes, it says nil < number in the error, so b.price does exist.
1 Like
So, how can I solve the problem? Like should I replace something or do I need to rescript
