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
2 years 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:

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

Modulescript:

01local Scale = {}
02local Players = game:GetService("Players")
03local Player = Players:GetPlayers()[1] or Players.PlayerAdded:Wait()
04local Char = Player.Character
05 
06 
07function Scale.Scaler(Scaling, Damage)
08    if Scaling == "D" then
09        local Factor = 45 / Char.ComboStats.Damage.Value
10        local Dmg = Damage * Factor
11        return math.round(Dmg)
12    end
13end
14 
15return Scale

1 answer

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

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

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

Answer this question