✓ Accepted answer
Keep in mind that Remote FUNCTIONS are used to relay data from server to client and vice versa. This means that info will be passed somewhat like this: ServerInputToClient > ClientRecievesInput > ClientInputToServer > ServerRecievesClientInput.
If you are only trying to do something like ServerImputToClient > ClientRecievesInput then you want to be using Remote EVENTS. I only tell you this because sometimes people will use remote functions when they really only need to use a remote event.
Here's an example of how to set up a remote function in which the client would request something from the server and return it to the client:
local repStorage= game:GetService("ReplicatedStorage")
local requestData = repStorage:WaitForChild("DataRequest")
local request = requestDatat:InvokeServer()
local repStorage= game:GetService("ReplicatedStorage")
local dataRequest = Instance.new("RemoteFunction",repStorage)
dataRequest.Name = "DataRequest"
local function DataRequested(player)
local request = DEFINEREQUESTHERE
return request
end
dataRequest.OnServerInvoke = DataRequested
2 comments
Ok but how would i reference that data sent to the local script in the local script?
That would be your "request". The server returns its definition of "request" to the client, making "requestDatat:InvokeServer()" whatever its definition in the server was.