I have a system in place which allows the player to increase the amount of coins he gets.
However, when increasing the amount of coins the person can get an error occurs,
‘Attempt to perform arithmetic on field “Multiplier” (a nil value)’
If anyone could help me as to what this means or how to fix it, i’d appreciate it.
Here’s the code:
function module.ChangeCoinMultiplier(plr, key, value)
if db == false then
db = true
local UserData = datastore2(MainKey, plr):Get(SetDataTable())
local values = datastore2("Values", plr)
UserData.Values.Multiplier = value
UserData.Values.Points = UserData.Values.Points - 1
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, 7031507) then
local multiplier = 1 + (0.5 * UserData.Values.Rebirths)
UserData.Values.Multiplier = (UserData.Values.Multiplier / (multiplier)) / 2
UserData.Values.Multiplier = (UserData.Values.Multiplier * multiplier) * 2
else
local multiplier = 1 + (0.5 * UserData.Values.Rebirths)
UserData.Values.Multiplier = UserData.Values.Multiplier / (multiplier)
UserData.Values.Multiplier = UserData.Values.Multiplier * multiplier
end
values:Set(UserData.Values)
wait(1)
db = false
end
end