|
| 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 |
|
|
| |
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|