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

Can someone help me with my error? Roblox attempted to perform an arithmetic.. what?..

Every time I test my game out, this error pops up: ServerScriptService.Main:13: attempt to perform arithmetic (add) on number and Instance. And I have no idea how to fix this! Here is my script, and I will only be showing the line that has my error.

game.ReplicatedStorage.Remotes.Add.OnServerEvent:Connect(function(player, amount) local currency = 'Cash' player.leaderstats.currency.Value = player.leaderstats.currency.Value + amount end)

Can someone please help me fix this?

1 answer

an arithmetic function is just a simple math operation, such as addition, subtraction, multiplication or division.

Your error states that the server is attempting to add a Number value and an Instance. An Instance cannot be added as it isn't a value.

I'd assume 'amount' is the issue, however I can't be sure as I cannot see the rest of your script, just the error line isn't very helpful for fixing errors, as we can't fully get a grasp on the context of the situation we're trying to fix.

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