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: Passing Functions through RemoteEvents?

Previous Thread :: Next Thread 
twister1976 is not online. twister1976
Joined: 17 Sep 2010
Total Posts: 2250
06 Feb 2016 10:49 PM
I've been trying to pass certain functions through RemoteEvents as the title states.

It works in Play Solo but not on a server, and idk why and if there is a workaround.

This is a simple script showing my problem.
--Server
game.ReplicatedStorage:WaitForChild("FunctionPassing").OnServerEvent:connect(function(plr, f)
f()
end)

--Client
local r = game.ReplicatedStorage:WaitForChild("FunctionPassing")
local mouse = game.Players.LocalPlayer:GetMouse()

mouse.KeyUp:connect(function(k)
k = k:lower()
if (k == "e") then
r:FireServer(function() print("wut") end)
end
end)

The only output it gives me in a server is that f is a nil value.

I'm just asking if anyone knows why or how I can bypass it.
Report Abuse
twister1976 is not online. twister1976
Joined: 17 Sep 2010
Total Posts: 2250
06 Feb 2016 11:00 PM
Bump
Report Abuse
R15E is not online. R15E
Joined: 18 Aug 2015
Total Posts: 84
06 Feb 2016 11:20 PM
Uhh, idk. Might be the fact you're making a string value into a function..



Follow me on twitter @RBX_BOBBY
Report Abuse
twister1976 is not online. twister1976
Joined: 17 Sep 2010
Total Posts: 2250
06 Feb 2016 11:23 PM
I believe it has something to do with this limitation:
'An instance that's only visible to the sender (local parts, descendants from the ServerScriptService, ...) will be replaced with nil.'

-http://wiki.roblox.com/index.php?title=RemoteFunction_and_RemoteEvent_Tutorial#Limitations
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
06 Feb 2016 11:31 PM
"It works in Play Solo but not on a server"

That's because the server IS the client.


Report Abuse
Ripepperoni is not online. Ripepperoni
Joined: 04 Jul 2010
Total Posts: 5715
07 Feb 2016 12:04 AM
don do that
that's really dumb and defeats the purpose of filtering enabled
just save a table of funciton on server and pass the server the function name
e.i


--server
local funcs = {
["foo"] = function(x)
print(x)
end,
}

remoteEvent.OnServerEvent:connect(function(a,b)
funcs[a](b)
end)

--local
remoteEvent:FireServer("foo","Lol")
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Feb 2016 12:05 AM
It's also impossible
Report Abuse
twister1976 is not online. twister1976
Joined: 17 Sep 2010
Total Posts: 2250
07 Feb 2016 10:36 AM
@Rip
That's my idea this morning.
And it did work, I just had to have the other table in another script because it was saying that the function in the table was nil so I made that table globle and accessed it to get functions on the client.

If money grew on trees... It would be as valuable as leaves. | Twitter: @TwisterRBLX


Report Abuse
Ripepperoni is not online. Ripepperoni
Joined: 04 Jul 2010
Total Posts: 5715
07 Feb 2016 12:19 PM
that wouldn't work either?

client global ~= server global
they are the same in testing mode but not ingame
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