Please show your full code.
There are ways to optimize how you'd like to do this, but ultimately you'll want to use a function that passes the frame. Also, you'd definitely want to set that function to local and pass the 'self' frame whatever that may be. For example:
Lua Code:
local function SetEnabled(info, newValue, frame, self)
UnitScanner_Settings["Bars"][self.CurrentBar]["enabled"] = newValue
if frame and type(frame) == "table" then
if (newValue == true) then frame:Show()
else
frame:Hide()
end
end
Alternatively you can use a indexed value on your checkbox button frame to indicate what frame to hide and assign it a general function and index itself.
Lua Code:
local function CheckboxOnClick(self)
local enabled = self:GetChecked()
local frame = _G[self.targetFrame] -- when creating the checkbox, you set this to the name of the frame you're wanting to hide.
UnitScanner_Settings["Bars"][frame:GetName()]["enabled"] = enabled
if enabled then
frame:Show()
else
frame:Hide()
end
end