You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to know what the problem with my elseIf statement and why it not working. -
What is the issue? Include screenshots / videos if possible!
I used __call metamethod to create a function for my table but elseIf Typecheck not working properly. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried to use different If checking but it still return the same error.
The main script:
local ReplicatedStorage:ReplicatedStorage = game:GetService("ReplicatedStorage")
local SharedFolder = ReplicatedStorage:WaitForChild("Shared")
--Variables
local Classes,Packages,Engine,Modules,Services,Assets,Remotes = {},{},{},{},{},{},{}
local FrameworkTree={
["Shared"]={
["Folder"] = SharedFolder,
["Classes"]={
["Data"] = {},
["Setting"]={
["Meta"]=true,
["Table"]=Classes,
["Folder"]={}
}},
["Packages"]={
["Data"] = {},
["Setting"]={
["Meta"]=true,
["Table"]=Packages,
["Folder"] = {}
}},
["Engine"]={
["Data"] = {},
["Setting"]={
["Meta"]=true,
["Table"]=Engine,
["Folder"] = {}
}},
["Modules"]={
["Data"] = {},
["Setting"]={
["Meta"]=true,
["Table"]=Modules,
["Folder"] = {}
}},
["Services"]={
["Data"] = {},
["Setting"]={
["Meta"]=true,
["Table"]=Services,
["Folder"] = {}
}},
["Assets"]={
["Data"] = {},
["Setting"]={
["Meta"]=false,
["Table"]=Assets,
["Folder"] = {}
}},
["Remotes"]={
["Data"] = {},
["Setting"]={
["Meta"]=false,
["Table"]=Remotes, --Somethings to do with?
["Folder"] = {}
}},
}
}
for k,a in pairs(FrameworkTree) do
local Folder = a.Folder
for c,b in pairs(a) do
if typeof(b) == "table" then
b["Setting"]["Folder"] = Folder[c]
if b["Setting"]["Table"] and b["Setting"]["Meta"] then
setmetatable(b["Setting"]["Table"],{
__index = b,
__call = function(Table,Object)
if Table["Setting"]["Folder"][Object]:IsA("ModuleScript") then
--Typecheck work
print(Object)
Object = require(Table["Setting"]["Folder"][Object])
elseif not Table["Setting"]["Folder"][Object]:IsA("ModuleScript") then
--Typecheck doesn't work but everything seem right
print(Object)
Object = Table["Setting"]["Folder"][Object]
else
--Else statement to check
print("C")
end
return Object
end,
})
end
end
end
end
Modules("test"):foo() --Print Foo
print(Remotes("RemoteEvent")) --Error Attempt to call a table value
The Place:
Place.rbxl (38.6 KB)