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

A problem with module stats values?

Asked by 5 years ago
Edited 5 years ago

Players.SunxLightz.Backpack.Pills.PillsS:11: attempt to perform arithmetic on field 'toHeal' (a nil value)

there a module named "STATS"

function HealUp(hum)

hum.Health = hum.Health + stats.toHeal

end

in module:

local module = {}



toHeal = 75



return module

1 answer

Log in to vote
0
Answered by 5 years ago

First, you need to have your "toHeal" variable inside the brackets of the module and you also need to make a variable inside your other script that requires the module. Example: In Module Script

local module = {
    toHeal = 75
    }
return module

In Script

local module = require(script.Parent.STATS) -- define the location of your module within the parenthesis
local toHeal = module.toHeal
local function HealUp(hum)
    hum.Health = hum.Health + toHeal
end

Hope this helps!

Ad

Answer this question