Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Attempt to perform arithmetic (sub) on number and nil error?

Asked by
NykoVania 231 Moderation Voter
1 year ago

I keep getting the error "Attempt to perform arithmetic (sub) on number and nil", I'm not sure what it means and haven't been able to find anything out about it.

Serverscript:

local ModuleScale = require(game:GetService("ServerScriptService").Scaling)
player.Character.Conditions.Health.Value -= ModuleScale.Scaler(Scaling, Damage)

Modulescript:

local Scale = {}
local Players = game:GetService("Players")
local Player = Players:GetPlayers()[1] or Players.PlayerAdded:Wait()
local Char = Player.Character


function Scale.Scaler(Scaling, Damage)
    if Scaling == "D" then
        local Factor = 45 / Char.ComboStats.Damage.Value
        local Dmg = Damage * Factor
        return math.round(Dmg)
    end
end

return Scale

1 answer

Log in to vote
1
Answered by
Puppynniko 1059 Moderation Voter
1 year ago
Edited 1 year ago

your module script failed to return a number therefor the Attempt to perform arithmetic (sub) on number and nil

--[[
number = player.Character.Conditions.Health.Value
nil = ModuleScale.Scaler()
Sub = Subtract
]]
0
How would the module fail to return a number? NykoVania 231 — 1y
0
its prob this "if Scaling == "D" then" if scaling is not D it returns nothing therefor nil Puppynniko 1059 — 1y
Ad

Answer this question