In a script inside a RemoteFunction, which is inside workspace, I have the following:
function script.Parent.OnServerInvoke(_) return function() print("hi"); end; end;
Then, inside a LocalScript, which is inside the StarterGui, I have the following:
local function loadstring(src) return workspace.RemoteFunction:InvokeServer(src); end; loadstring()();
This causes the following error:
12:35:23.263 - Players.Player1.PlayerGui.LocalScript:4: attempt to call a nil value 12:35:23.263 - Stack Begin 12:35:23.263 - Script 'Players.Player1.PlayerGui.LocalScript', Line 4 12:35:23.263 - Stack End
What's wrong with this application?
As I'm not quite positive why this is happening I will give two posibilities.
1: The return function is actually returning the return value of the function due to some strange evaluation priority. 2(more likely). I'm fairly sure that a function when defined takes a snapshot of the variable environment which is certainly a security concern if you're moving this function to the client. Why ROBLOX made the return value nil rather then just erroring when a function is returned I don't know.