22:15:23.834 - ServerScriptService.Script:19: attempt to perform arithmetic (sub) on Instance and number

game.Players.PlayerAdded:Connect(function(plr)
	local leaderstats = Instance.new("Folder")
	leaderstats.Parent = plr
	leaderstats.Name = "leaderstats"
	
	local iq = Instance.new("IntValue")
	iq.Name = "IQ"
	iq.Parent = plr
	iq.Value = 300
	
	local IQ = Instance.new("IntValue")
	IQ.Name = "IQ"
	IQ.Parent = leaderstats
	IQ.Value = 0
	
while true do
	  wait(30)
	print("IQ Subtracted")
    iq = iq - 30
end
end)

This is the error

  22:15:23.834 - ServerScriptService.Script:19: attempt to perform arithmetic (sub) on Instance and number
22:15:23.835 - Stack Begin
22:15:23.836 - Script 'ServerScriptService.Script', Line 19
22:15:23.838 - Stack End

What did i do wrong?

3 Likes

I think you instead want to do iq.Value = iq.Value - 30. You can’t subtract the IntValue object.

1 Like

You get their instances, not value. Replace it by iq.Value.
(You get it by their name, not value.)
Luau is very confusing, that it’s impossible to subtract string with numbers. (except for string.sub) But by add with ‘value’, it will make easier for luau and luau finally understand it was number.

2 Likes

my bad i didn’t noticed maybe i need more sleep i’m out of my mind today lol

I have that same error right now but my datastore is using .Value. :frowning: I have no idea what mine is doing wrong but glad I seen this too because I have left .Value out before also.

1 Like