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
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.
I have that same error right now but my datastore is using .Value. I have no idea what mine is doing wrong but glad I seen this too because I have left .Value out before also.