Attempt to perform arithmetic (mul) on Instance and Number

Hello everyone,

I was just messing around the studio, While I got the following Error.

“Attempt to perform arithmetic (mul) on Instance and Number”

Here is my code:

game.ReplicatedStorage.Events.Substation.OnServerEvent:Connect(function(player)
local Subs = player.leaderstats.SubStation
if Subs.Value == 2 then
Subs.Value = Subs*10
end
end)

Can someone help me to figure what does this mean, and how do I get around it?

Because you are multiplying an Instance (a ValueObject, Sub) by a number (10), as simple as that.

How would I fix it though? I have tried to work around it but it would not work.

Instead of Subs.Value = Subs*10, you should do Subs.Value = Subs.Value * 10, if you have trouble remembering to do that you could also go with a shorter approach and do Subs.Value *= 10

4 Likes

I was just a bit dumb, I forgot to specify the Value part in the multiplication, Anyways thanks for the help.