Can you pass a function through a remote event?

(post deleted by author​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​)

1 Like

No, it doesn’t, because he is sending from the server to the client and not vice versa. Even still, use of loadstring is questionable there is often times always a better solution.

It’s completely ridiculous to ship a custom interpreter with your game when you can just put the code you want to invoke in a module script. So much bloat for no reason, while the correct alternative approach is so simple and intuitive.

There is never a situation where you have to invoke variable code on the client from the server during normal game development. It indicates bad system design/architecture of your game if you feel that you need this. Any functionality you need the client to do can be pre-programmed in modules on the client-side and then delegate to that implementation.

What about using Corountines? I think it may be possible that you can make a function that can be passed over with Corountines:

Example
local Function = corountine.create(function() print("test") end)

function Execute(x)
corountine.resume(x)
end

Execute(Function)

Not sure why you would wanna pass Functions through a RemoteEvent in the first place though.

That’s off-topic – this post is about networking, not threading.