Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

A problem with module stats values?

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

✓ Accepted answer

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.