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

attempt to perform arithmetic (mul) on number and Instance?

Asked by 3 years ago

I am trying to multiply coins using string values that are attached to the player, one of the string values attached to is Pickaxe, this is the pickaxe that is saved when they join the game, inside the pickaxe is a multiplier value which will multiply the coins, here I tryed getting the Item in the ReplicatedStorage by using the value attached to the player, but it didn't work and the title is the error

local shopkeeper = game.Workspace:FindFirstChild("Sell your ore here!")
local guiNoticeEvent = game.ReplicatedStorage:WaitForChild("GUINoticeEvent")
RepStor = game:GetService("ReplicatedStorage")
function onTouch(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    if (humanoid and humanoid ~= shopkeeper) then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if (player.InventoryValue.Value > 0) then
            local savedValue = player.InventoryValue.Value
            player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + player.InventoryValue.Value * RepStor[player.Pickaxe.Value]
            player.InventoryValue.Value = 0
            player.InventoryCount.Value = 0
            guiNoticeEvent:FireClient(player, 0, savedValue)
        end
    end
end
script.Parent.Touched:Connect(onTouch)

1 answer

Log in to vote
0
Answered by 3 years ago

The errors says whats wrong ur trying to multiply a number and an instance player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + player.InventoryValue.Value * RepStor[player.Pickaxe.Value] it happens on this line more specific

player.InventoryValue.Value * RepStor[player.Pickaxe.Value] because RepStor[player.Pickaxe.Value] is not a number but an instance

0
Thank you so much! DARWINTHEMINION2 37 — 3y
0
Also I corrected the error but it wont multiply, it now says RepStor[player.Pickaxe.Value].multiplier.Value DARWINTHEMINION2 37 — 3y
0
what error are you getting VerdommeMan 1479 — 3y
Ad

Answer this question