Attempt to perform arithmetic (sub) on Boolean and number

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    get rid of the error
  2. What is the issue? Include screenshots / videos if possible!
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Nothing, don’t see where the issue is located exactly.

Script where line 77 is located:

local API = {}
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Assets = require(ReplicatedStorage.Databases.Assets)
local Constants = require(ReplicatedStorage.Databases.Constants)
local bankValues = {Bank = 0, Cash = 0}
local ValueBox = {}
ValueBox.__index = ValueBox
local bankFrame = ValueBox.new(Assets.IconRect.Bank)
local cashFrame = ValueBox.new(Assets.IconRect.Cash)
local RemoteHandler = require(script.Parent.RemoteHandler)
local updateRemote = RemoteHandler.Event.new("BankUpdate")
local RoundNumber = function(num, numDecimalPlaces)
		return string.format("%." .. (numDecimalPlaces or 0) .. "f", num)
	end
	local function ShortenNumber(num)
		return math.abs(num) > 999 and RoundNumber(num / 1000, 1) .. "k" or num
	end
	updateRemote.OnEvent:Connect(function(bType, val)
		if bType == 1 then
			local diff = val - bankValues.Bank
			bankValues.Bank = val
			bankFrame:SetValue("$" .. ShortenNumber(bankValues.Bank), diff)
			bankFrame:SetExactValue("$" .. bankValues.Bank)
		else
			local diff = val - bankValues.Cash
			bankValues.Cash = val
			cashFrame:SetValue("$" .. ShortenNumber(bankValues.Cash), diff)
			cashFrame:SetExactValue("$" .. bankValues.Cash)
		end
	end)
	local function getStat(val)
		if val == "Bank" then
			return bankValues.Bank
		elseif val == "Cash" then
			return bankValues.Cash
		end
	end

Line 77:

local diff = val - bankValues.Bank

Can we see the program causing this error? Somewhere your subtracting a true/false with a number (which obviously won’t work).

Just added it in, sorry lol…

The only subtraction I see taking place is in the if statement so check both values and make sure their the correct inputs by placing a print statement just before subtracting them to see whats being put in.

EX:
print(val)
print(bankVales.Bank)

Just edited, so look at the edit I made.

What’s supposed to be inputted for val?

Here val is a string.

updateRemote.OnEvent:Connect(function(bType, val)
local function getStat(val)

Val is a boolean and not a number so it’s not subtractable, what is val supposed to be? Check where its defined or passed in and make sure its a number and not a string bc I see from that function it’s a string (which can’t be subtracted).

I don’t think Val is defined as the correct object in this script.

I’m confused, what is val supposed to be?

I think it’s supposed to be a value in which the bank number value gets subtracted/auditioned in the scripting.

local diff = val - bankValues.Bank

Check where the values being passed in and make sure the correct value is assigned to val because right now it’s a non numeric value so they can’t be subtracted.

Thing is I can’t, because Val is being created as an Object via:

updateRemote.OnEvent:Connect(function(bType, val)

and

local function getStat(val)
		if val == "Bank" then
			return bankValues.Bank
		elseif val == "Cash" then
			return bankValues.Cash
		end
	end

Val is the same in both functions right? If so I’m not sure what your trying to do since you can’t subtract a number and string value.

How would I convert this Val object to whatever it’s supposed to be then?

Is val supposed to be what’s returned in getStat?

updateRemote.OnEvent:Connect(function(bType, val)
		if bType == 1 then
			local diff = val - bankValues.Bank
			bankValues.Bank = val
local diff = val - bankValues.Cash
			bankValues.Cash = val

nvm i found what val is defined as

Val isn’t defined in either of those code blocks.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Assets = require(ReplicatedStorage.Databases.Assets)
local ValueBox = {}
ValueBox.__index = ValueBox
local bankValues = {Bank = 0, Cash = 0}
local bankFrame = ValueBox.new(Assets.IconRect.Bank)
local cashFrame = ValueBox.new(Assets.IconRect.Cash)

Not there either. In a function the value passed in as an argument would look something like this.

local val = 5 -- Variable 'val' is defined.

function printVal(val) -- Function printVal.
     print(val)
end

printVal(val) -- Function printVal is ran with the variable passed in as an argument.