generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Transferring Functions To Server

Previous Thread :: Next Thread 
ninja900500 is not online. ninja900500
Joined: 27 Sep 2008
Total Posts: 2324
08 Jun 2016 06:57 PM
How come you can't transfer a function to a server through a remote event?

For example:

In Local Script:
RemoteEvent:FireServer(
Table = {
TestFunction = function()
end
}
)

In Server:
RemoteEvent.OnServetEvent:connect(function(Table)
print(Table.TestFunction)
end)

How come "TestFunction" is non existent on the server?
Report Abuse
ninja900500 is not online. ninja900500
Joined: 27 Sep 2008
Total Posts: 2324
08 Jun 2016 07:02 PM
bump
Report Abuse
ninja900500 is not online. ninja900500
Joined: 27 Sep 2008
Total Posts: 2324
08 Jun 2016 07:33 PM
bump 2
Report Abuse
Rerumu is online. Rerumu
Joined: 11 Oct 2014
Total Posts: 950
08 Jun 2016 07:47 PM
You can't pass functions as arguments in between server and client in any way. I've tested it but your best bet is to send the server a string to loadstring()()
Report Abuse
ninja900500 is not online. ninja900500
Joined: 27 Sep 2008
Total Posts: 2324
08 Jun 2016 08:46 PM
example please

:)
Report Abuse
Rerumu is online. Rerumu
Joined: 11 Oct 2014
Total Posts: 950
08 Jun 2016 09:13 PM
I tried JSON encoding them, didn't even work.
Report Abuse
Rerumu is online. Rerumu
Joined: 11 Oct 2014
Total Posts: 950
08 Jun 2016 09:17 PM
local func = [[
function Stuff(that)
local this = 2
return that*this
end
]]

-- Send the func string over through remote function/event.
-- On server script you would then do:

local func = ExampleFunction:InvokeClient(player) -- Ex. Of getting the string.

loadstring(func)(Insert_Arguments_Here) -- Call the code.
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
08 Jun 2016 09:35 PM
Probably because the first argument of OnServerEvent is player


Report Abuse
Rerumu is online. Rerumu
Joined: 11 Oct 2014
Total Posts: 950
08 Jun 2016 10:37 PM
There is an actual issue with function passing though, same with dictionaries. Overlooking the syntax errors there is a ROBLOX limitation for it.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
08 Jun 2016 10:41 PM
Why would Roblox go to the vast effort of allowing you to pass functions through them, when it wouldn't even be practical for anything but messing around?


Report Abuse
Rerumu is online. Rerumu
Joined: 11 Oct 2014
Total Posts: 950
08 Jun 2016 10:47 PM
Because messing aroUND IS LIFEEE.
That's how I made my Text Filter script, by messing around.
And by messing around it outclassed ROBLOX's own filter.
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
08 Jun 2016 11:38 PM
Do you know how insanely complicated it would be to implement passing functions across the server-client boundary? You don't think of it now but you have to clone the function's environment, the upvalues, and the prototype itself. The environment and upvalues may, and probably will, contain other functions, tables, userdata that exists only on the client (of which may also contain functions and so on). It's incredibly impractical, and even if it were possible if you find a need to actually send a function then you are most likely doing something wrong.
Report Abuse
Rerumu is online. Rerumu
Joined: 11 Oct 2014
Total Posts: 950
08 Jun 2016 11:44 PM
I'm not talking about the function with the entire environment this and that, I'm saying the body of the function itself. Passing a function as in:

function Add(a,b)
return a+b
end

Now if a variable were to be defined somewhere else outside the function:

function Add(a)
return a+b -- b is defined outside of function body.
end

Then ROBLOX could simply nil it.
It's as easy as making the function to string and loadstring'ng it on the server before usage.
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
09 Jun 2016 12:01 AM
No, because a lot of people would complain lol
Report Abuse
Hedr0n is not online. Hedr0n
Joined: 05 Jan 2016
Total Posts: 1524
09 Jun 2016 12:48 AM
@cn where do I go to get a Lua vm installed into my brain like you
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image