The error is [ServerScriptService.BuyScript:5: attempt to compare Instance and string]
I have tries to do some solutions but they dot work so far.
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local RemoteEvent = ReplicatedStorage:WaitForChild(“BuyTool”)
local function buyTool(player, tool)
if player.leaderstats.Orbs.Value >= tool.Price then
player.leaderstats.Orbs.Value = player.leaderstats.Orbs.Value - tool.Price.Value
end
local giveTool = ReplicatedStorage.ShopItems[tool.Name]:Clone()
giveTool.Parent = player.Backpack
local giveTool = ReplicatedStorage.ShopItems[tool.Name]:Clone()
giveTool.Parent = player.StarterGear
end
RemoteEvent.OnServerEvent:Connect(buyTool)
When i click on the error i go to this line
if player.leaderstats.Orbs.Value >= tool.Price then
I’m guessing that there’s is an instance of class “IntValue” or “StringValue” as a child of your tool and the name of this instance is called “Price”.
When doing:
if player.leaderstats.Orbs.Value >= tool.Price then
I believe that player.leaderstats.Orbs.Value refers to the “Value” property of that instance, of which the datatype for that is a string. However, tool.Price would refer to the entire instance of which the datatype is an instance. So when you compare a string to an instance, you get the exception that was printed to your console!
To rectify this, perhaps try if player.leaderstats.Orbs.Value >= tool.Price.Value then in place of that current line of code?
EDIT: Also, I would recommend changing the subclass of your Orbs instance to that of a IntValue or NumberValue if not already done so as suggested by @Xx_FROSTBITExXif you wished to compare the numerical value of the price and orbs. (Which is what I believe you want to do.) Otherwise, if you try to compare two strings, the lua interpreter will simply try to compare the strings alphabetically. (So "a" > "b" will output false, as it is “b” that comes after “a” alphabetically). If you try to compare say a string and a number however, you will get an exception saying “attempt to compare number and string”.