I have tried to edit a script, so that there can be handling more stats (removed as it's not the main idea). But when I test it, it would say
19:18:51.212 - ServerScriptService.Script:27: attempt to perform arithmetic on local 'oldValue' (a boolean value)
19:18:51.213 - Stack Begin
19:18:51.215 - Script 'ServerScriptService.Script', Line 27
19:18:51.216 - Stack End
Are there any solutions for getting rid of this error? Or is it ROBLOX bug?
Faulty code:
local replicated = game:GetService("ReplicatedStorage")
local DataStore = game:GetService("DataStoreService"):GetDataStore("essintials")
game.Players.PlayerAdded:connect(function(player)
--create leadstats
local leadstats = Instance.new("IntValue")
leadstats.Name = "leaderstats"
leadstats.Parent = player
local money = Instance.new("IntValue")
money.Name = "Money"
money.Value = 0
money.Parent = leadstats
local exp = Instance.new("IntValue")
exp.Name = "Experience"
exp.Parent = leadstats
local level = Instance.new("IntValue")
level.Name = "Level"
level.Parent = leadstats
local team = Instance.new("StringValue")
team.Name = "Team"
team.Value = "None (Deciding)"
--datastore
local key = "user_" .. player.userId
--increase by 100 money per entering
DataStore:UpdateAsync(key, function(oldValue)
local newValue = oldValue + 100
local addedValue = oldValue == newValue
money.Value = addedValue
return addedValue
end)
end)
