Hello,sorry I am very bad at explaining but I’ll try to explain the best I can!
I am trying to practice and use metatables
for the first time. I am using this for help and reference. Everything seemed alright when I doing this, but when I tried to call self.exposure
, it returned nil
unless I re-value it like this
self.exposure = 2
But if I try keeping the value I give it from the module, it just returns nil.
--**MODULE**--
local LightingEffects = {}
LightingEffects.__index = LightingEffects
function LightingEffects.Activate(ExposureBrightness, Saturation, Contrast, Blur, showNightVisionLight)
print("Active")
local newEffects = {
exposure = ExposureBrightness,
saturation = Saturation,
contrast = Contrast,
blurness = Blur,
showNightLight = showNightVisionLight,
}
return setmetatable(newEffects, LightingEffects)
end
function LightingEffects:AddEffects()
print("adding")
local exposure = self.exposure
print(exposure) --> The value should be at the value I set it at, but instead, it's nil.
end
return LightingEffects
--**SCRIPT**--
local module = require(path)
module.Activate(1, 2, 3, 4, false) --exposure, saturation, contrast, blur, bool
module:AddEffect() --> returns nil ?
When I do it like this, it just returns nil, but when I, again, forcefully change it, it will change. For example;
function LightingEffects:AddEffects()
print("adding")
local exposure = self.exposure
exposure = 2
print(exposure) --> returns 2
end
I hoped this made sense, any help would be appreciated! (Don’t be scared to ask for more clarification )