Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

What does this error mean??

Asked by
lucas4114 607 Moderation Voter
8 years ago

"attempt to compare two userdata values" ?????? Output: "18:33:15 -- attempt to compare two userdata values 18:33:19 -- Script 'Players.lucas4114.PlayerGui.ScreenGui.TradeMenu.TradingMenu.Market.Shop.LoadShopUnits', Line 18 18:33:19 -- Stack End" Script:

script.Parent.Changed:connect(function(vis)
    if vis == "Visible" then
        if script.Parent.Visible == true then
            local itemstodelete = script.Parent:GetChildren()
            for i,v in pairs (itemstodelete) do
                if v:IsA("ImageButton") then
                    v:Destroy()
                end
            end
            local marketunitswithprice = {}
            local unitval = game.Workspace.SaveGlobalMarket.Items:GetChildren()
            for i,v in pairs (unitval) do
                marketunitswithprice[v.Price.Value] = v
            end
            table.sort(marketunitswithprice)
            for price, marketunit in pairs (marketunitswithprice) do
                local unit = game.ServerStorage.UNITS:FindFirstChild(marketunit.Name)
                local ItemGui = game.ServerStorage.MarketShopItemGui:Clone()
                ItemGui.Name = unit.Name
                ItemGui.Parent = script.Parent
                local ItemGuisinmarket = 0
                for i,v in pairs (script.Parent:GetChildren()) do
                    if v:IsA("ImageButton") then
                        ItemGuisinmarket = ItemGuisinmarket + 1
                    end
                end
                local Ypos = ((ItemGuisinmarket - 1)*130)
                ItemGui.Position = UDim2.new(0,10,0,Ypos +6)
                ItemGui.Frame.ItemInGlobalMarket.Value = marketunit
                ItemGui.Frame.Player.Value = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Name
                ItemGui.Frame.ImageLabel.Image = unit.Stats.RespawnGuiImageId.Value
                ItemGui.Frame.UnitDamage.Text = "Damage: "..unit.Stats.Damage.Value
                ItemGui.Frame.UnitDescription.Text = unit.Stats.Description.Value
                ItemGui.Frame.UnitHealth.Text = "Health: "..unit.Humanoid.MaxHealth
                ItemGui.Frame.UnitName.Text = unit.Name
                ItemGui.Frame.UnitPrice.Text = "Price: "..marketunit.Price.Value.." Gold."
                ItemGui.Frame.UnitRange.Text = "Range: "..unit.Stats.Range.Value
                ItemGui.Frame.UnitReloadTime.Text = "Reload Time: "..unit.Stats.ReloadTime.Value
                ItemGui.Frame.UnitRespawnTime.Text = "Respawn Time: "..unit.Stats.RespawnTime.Value
                ItemGui.Frame.UnitSpeed.Text = "Speed: "..unit.Humanoid.WalkSpeed
                ItemGui.Frame.UnitType.Text = unit.Stats.Type.Value
                ItemGui.Frame.BackgroundColor3 = unit.Stats.RespawnGuiBorderColor.Value
                ItemGui.Frame.UnitName.TextStrokeColor3 = unit.Stats.RespawnGuiTextOutlineColor.Value
                ItemGui.Frame.UnitName.TextColor3 = unit.Stats.RespawnGuiTextColor.Value
                if ItemGuisinmarket/2 == math.floor(ItemGuisinmarket/2) then
                    script.Parent.CanvasSize = UDim2.new(0,0,(ItemGuisinmarket/2 + 1),0)
                end
            end
        end
    end
end)
0
Could you provide the script so that we could get a better understanding please? minikitkat 687 — 8y
0
Ok lucas4114 607 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

You are probably comparing two values such as if you were to compare a position and if you say something like this....

local torso = player.Character.Torso
if torso.Position >= Vector3.new(5,5,5) then
print("Wow...")
end

Now the code above will have an error stating that you're comparing two userdata values but, you could use magnitude for the above example.. So if that is your problem try using magnitude or some other method. Thank you for reading this answer. Hope it helped you out.

0
But I'm using table.sort(), I'm not comparing anything. lucas4114 607 — 8y
0
And in the table are int values, not Vector3s how would I use magnitude to compare that? lucas4114 607 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

As you can see on the error, the problem is in Line 18

0
But what does it mean? How do I fix it? It was just table.sort() how do I fix that? lucas4114 607 — 8y

Answer this question