I’m trying to pass an event to the client that will run a function on the client with the argument func that refers to the name of the function I wanna call and ... being optional arguments.
Server:
remotes.InvokeClient:FireAllClients("PrintMsg", "Hi! I'm working")
Client:
remotes.InvokeClient.OnClientEvent:Connect(function(func, ...)
MainHandler[func](...) -- the function is being called but 'nil' is received as an arg
end)
Any ideas why this may not work? Tried searching for a while but I couldn’t find anything that could help me. Thanks.
Oh, this is because of how the colon works.
Basically:
function foo.Bar(object, s)
end
function foo:Bar(s) -- object is automatically being passed in when called with the :
end
So basically, when you call the function like that in the main script, it acts like the dot function, resulting in msg being nil. So replace the colon with a dot.