I have an ObjectValue in the server. How can I get it from a client?
✓ ANSWER ACCEPTED
How to get a server value from a LocalScript?
1 answer
✓ Accepted answer
You can use a RemoteFunction! This will allow the Client to invoke a function designated on the Server, which we can simply write to return the ObjectValue's Value:
####Ensure to place this Instance in a container in which both the Client & Server can reference; ReplicatedStorage is preferred:
--// Server-sided Script ("Regular")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteFunction = ReplicatedStorage.RemoteFunction
local ObjectValue = script.ObjectValue
RemoteFunction.OnServerInvoke = function()
---------------
return ObjectValue.Value
end
--// LocalScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteFunction = ReplicatedStorage:WaitForChild("RemoteFunction")
print(RemoteFunction:InvokeServer()) --> Object
This discussion is preserved as it was. New answers, comments, and votes are closed.
