I was writing a new framework for my newer project but I’ve gotten into a big problem, I have been attempting to find a solution to this problem for the past few hours and I still have not a single clue what is causing this.
for some reason the methods aren’t copied
output:
the first table are the methods
the second table is the table after the meta was supposed to be copied
network.CreateConnection = function(self, connection_name, connection_type, connection_global)
-- * Error check
assert((typeof(connection_name) == "string"), GetErrorCode("Invalid Argument, Argument 1(connection_name): String expected"))
assert((typeof(connection_type) == "string"), GetErrorCode("Invalid Argument, Argument 2(connection_type): String expected"))
assert(((connection_global == true) and (IsServer)) or (connection_global == false), GetErrorCode("Invalid Usage, global connection can only be created from the server") )
-- x assert((typeof(connection_name) == "boolean"), GetErrorCode("Invalid Argument, Argument 3(connection_global): Boolean expected"))
-- * Defaulting
connection_global = (typeof(connection_global) == "boolean") and connection_global or false
-- * Creates meta
local this = setmetatable({}, connection_methods)
warn(this, connection_methods)
-- * Set properties
this.Name = connection_name
this.Type = connection_type
this.connection_global = connection_global
this.Connection = ((connection_global == false) and (connection_type == "Set"))
and BindableEvent:Clone()
or ((connection_global == false) and (connection_type == "Get"))
and BindableFunction:Clone()
or ((connection_global == true) and (connection_type == "Set"))
and RemoteEvent:Clone()
or ((connection_global == true) and (connection_type == "Get"))
and RemoteFunction:Clone()
or "Cancel"
this.ConnectMethod = ((connection_global == false) and (connection_type == "Set"))
and "Event"
or ((connection_global == false) and (connection_type == "Get"))
and "OnInvoke"
or ((connection_global == true) and (connection_type == "Set"))
and ((IsClient == true) and "OnClientEvent" or "OnServerEvent")
or ((connection_global == true) and (connection_type == "Get"))
and ((IsClient == true) and "OnClientInvoke" or "OnServerInvoke")
or "Cancel"
if (connection_type == "Get") then
this.InvokeMethod = ((this.connection_global == true) and (IsClient))
and "InvokeServer"
or ((this.connection_global == true) and (IsServer))
and "InvokeClient"
or ((this.connection_global == false))
and "Invoke"
or "Cancel"
end
--
if (this.Connection == "Cancel") or (this.Connection == nil) then
this:Destroy()
warn(GetErrorCode("Failed to create connection: Invalid arguments(Connection)"))
return
end
if (this.ConnectMethod == "Cancel") or (this.ConnectMethod == nil) then
this:Destroy()
warn(GetErrorCode("Failed to create connection: Invalid arguments(ConnectMethod)"))
return
end
if (this.Type == "Get") and ((this.InvokeMethod == "Cancel") or (this.InvokeMethod == nil)) then
this:Destroy()
warn(GetErrorCode("Failed to create connection: Invalid arguments(InvokeMethod)"))
return
end
if (this.connection_global) and (IsServer) then
SetCommunication:FireAllClients(this.Name, this.Type)
end
connections[this.Type][(this.connection_global) and "Com" or "Local"][this.Name] = this
return this
end
local connection_methods = {}
connection_methods.__index = connection_methods
-- * Connect
-- * Arguments
-- * func (function)
-- * Callback
connection_methods.Connect = function(this, func)
if (this.Type == "Set") then
this.Connection[this.ConnectMethod]:Connect(func)
elseif (this.Type == "Get") then
-- * Overwrites the get function and replace it with the new function
-- * Only one Function can exist at once, it's pointless to have two receivers
-- * then to have them return different arguments, only one would go through
if (typeof(this.GetFunc) == "function") then
warn("$m Warn: Existing function was overridden:", this.Name)
end
this.GetFunc = func
this.Connection[this.ConnectMethod] = this.GetFunc
end
end
im extremely sorry for the lack of explaination in this post, I’m exhausted and suffering from my back pain
I would appreciate any help