Attempt to perform arithmetic (sub) on instance

Hello!

I have made an overhead gui system where players can unlock special overheads (e.g. starter, rookie, beginner, etc), and the script which inside the “Equip” script (local script inside of a button), it comes up with an error, this is the code below:

local replicatedStorage = game.ReplicatedStorage
local events = replicatedStorage.RemoteEvents.TitleEvents

events.Beginner.OnServerEvent:Connect(function(plr)
	local titleFolder = plr.TitleFolder
	local titleStat = titleFolder.TitleStat
	
	titleStat = (titleStat - titleStat) + 2
end)

This is the Beginner event script, which is what the LocalScript is trying to fire but ends up coming with this error:

I’m trying to make a value become a certain value by subtracting the value and then adding a specific value (I know it sounds complicated, I’m more than happy to explain the system if you’d like me to), for example, if the titleStat value is 5, then it does 5-5, then adds 2 since the beginner value is 2 and the overhead gui text changes, or should change, to “Beginner” once the value is 2.

I’m sorry it sounds so complicated but I can explain the full system if you’d like me to!

Thank you!

You have to put in titleStat.Value, since you are trying to change the value

1 Like

Oh yes, I just realised that I didn’t put the .Value. I’m very tired I’ve made a lot of mistakes in my code today lol :sweat_smile: