I'm trying to be really modular in the design of this game, I want to hook roblox gui instances to a class with methods, relating to gui appearance and display. But I'm unable to call what I believe is a callable method.
Local script in ReplicatedFirst:
print'loadhandler started'
--//Services
local _plrs = game:GetService'Players'
local _shared = game:GetService'ReplicatedStorage'
--//Constants
local _plr = _plrs.LocalPlayer
local _client = _plr:WaitForChild'PlayerScripts'
local _g = game
local _s = script
local _p = script.Parent
local _loaded = _s:WaitForChild'Loaded' --bindableevent in script
--//Modules
local clientModules = require(_client:WaitForChild'Modules') --a single module that holds required modules in it
--//Variables
local plrGui = _plr:WaitForChild'PlayerGui'
local mainGui = plrGui:WaitForChild'MainGui'
local screenFrame = mainGui:WaitForChild'ScreenFrame'
local loadingFrame = clientModules.GuiClass.new(screenFrame:WaitForChild'LoadingFrame')
local loadLabel = screenFrame.LoadingFrame:WaitForChild'LoadingLabel'
local skipButton = clientModules.GuiClass.new(loadLabel:WaitForChild'SkipButton')
local loadText = clientModules.GuiClass.new(loadLabel:WaitForChild'LoadText')
local loading = true
--//Code
loadingFrame:Open()
loadText:ChangeText'Loading Assets'
Module script in starterplayerscripts
local GuiClass = {}
local GuiMethods = {}
function GuiClass.new(Arg)
return setmetatable({gui = Arg} or {gui = nil},GuiMethods)
end
function GuiMethods:Open(style)
print'opening'
if style == nil then
self.gui.Visible = true
end
end
function GuiMethods:Close(style)
print'closing'
if style == nil then
self.gui.Visible = false
end
end
function GuiMethods:ChangeText(text)
self.gui.Text = text
end
return GuiClass`
Error: ReplicatedFirst.LoadingHandler:29: attempt to call method 'Open' (a nil value) Stack Begin Script 'ReplicatedFirst.LoadingHandler', Line 29 Stack End
