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

How to fix a issue where the outpout says attempt to compare number with string?

Asked by
hokyboy 270 Moderation Voter
4 years ago

Output: Players.hokyboy.PlayerGui.Shop.Frame.Buy.LocalScript:8: attempt to compare number with string

script

local player = game.Players.LocalPlayer
local currency = player:WaitForChild("leaderstats")["????Coins"] -- Currency Name here.
local item = script.Parent.Parent.Parent.Item
local shop = game.Workspace.Shop
local tool = game.ReplicatedStorage:WaitForChild("Tools")

script.Parent.MouseButton1Click:Connect(function()
    if currency.Value >= shop:FindFirstChild("Part"..item.Value).ItemPrice.Value then
        if player.Backpack:FindFirstChild(shop:FindFirstChild("Part"..item.Value).ItemName.Value) == nil then
            if shop:FindFirstChild("Part"..item.Value) then
                currency.Value = currency.Value - shop:FindFirstChild("Part"..item.Value).ItemPrice.Value
                script.Parent.Text = "Bought"
                script.Parent.BackgroundColor3 = Color3.new(0.7,0.7,0.7)
                script.Parent.Shadow.BackgroundColor3 = Color3.new(0.5,0.5,0.5)
                game.ReplicatedStorage.ShopBuy:FireServer(item.Value)
            end
        end
    end
end)
0
What is the classname of item? (Bool, Object, String, etc...) cegberry 432 — 4y
0
Item name is a string value price is a IntValue hokyboy 270 — 4y
0
Also tried numbervalue doesnt work either hokyboy 270 — 4y

Answer this question