|
| 02 Jun 2016 06:38 PM |
I want a local script to call to a server, then the server the call back.
Example
Localscript> "Files please" Serverscript> "game.Workspace.Folder:GetChildren()" |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2016 06:42 PM |
| Like I think RemoteFunction is for this... But like..... How would I set up an event and everything to recieve it and to send data back and forth |
|
|
| Report Abuse |
|
|
GGGGG14
|
  |
| Joined: 29 Jan 2012 |
| Total Posts: 25344 |
|
|
| 02 Jun 2016 06:44 PM |
--Step 1) Place a RemoteEvent into the ReplicatedStorage (both the server & client can access this service) --Step 2) Name it something that is useful to what you are trying to do. --Step 3) Script!
--Local Script:
local RepStore = game:GetService("ReplicatedStorage") local event = RepStore:WaitForChild("MyEvent")
event:FireServer(string)
--Server Script:
local RepStore = game:GetService("ReplicatedStorage") local event = RepStore:WaitForChild("MyEvent")
local onMyEvent = function(string) print(string) end
event.OnServerEvent:connect(onMyEvent) |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2016 06:47 PM |
server
workspace.RemoveFunction.OnServerInvoke:connect(function(Player) return game.Workspace.Folder:GetChildren() end)
localscript
local ToReturn = workspace.RemoteFunction:InvokeServer() print(ToReturn)
--Will print a table since it returned the children. |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2016 06:48 PM |
| WHY AM I SPELLED "REMOTE" AS "REMOVE" EVERY TIME |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2016 06:56 PM |
I am having trouble understanding how this would transfer back to the localscript.
I thought you needed to use returns.
Thanks guys just a little clarifications.
and ChamptionBuilder your a legend builder+coder O_O |
|
|
| Report Abuse |
|
|
Ben1925
|
  |
| Joined: 07 Apr 2011 |
| Total Posts: 741 |
|
|
| 02 Jun 2016 07:07 PM |
| You _do_ use returns. The server returns the result, the client receives it. |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2016 08:32 PM |
OnServerInvoke is a callback member of RemoteFunction; you can only set the callback value, get is not available
is the error |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2016 08:38 PM |
| chamption understands i need to return it but his code is faulty :( |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 03 Jun 2016 08:58 PM |
oh do this instead
function workspace.RemoteFunction.OnServerInvoke(Player) return --blahblah end |
|
|
| Report Abuse |
|
|
| |
|
| |
|