Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

3 comments

0

Thank you so much!

0

Also I corrected the error but it wont multiply, it now says RepStor[player.Pickaxe.Value].multiplier.Value

0

what error are you getting

This discussion is preserved as it was. New answers, comments, and votes are closed.