Hello! I am working on optimizations, and I am currently stuck with getting stuff from the Server to the client.
Here is my approach so far:
Client
local Karts = ReplicatedStorage.ClientRequest.GetKarts:InvokeServer()
print(Karts)
for _, Bodies in pairs(Karts:GetChildren()) do
-- Keep going here
Server
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
ReplicatedStorage.ClientRequest.GetKarts.OnServerInvoke = function(Player)
local Karts = ServerStorage.KartParts:Clone()
return Karts
end
And I keep getting this in the output:
The “Getting Karts” is from my Refresh function.
If you can help solve this, that would be appreciated!
Thanks in advance!
Instead of using ServerStorage, use ReplicatedStorage. ServerStorage can only be accessed by the server, ReplicatedStorage can be accessed by both the server and the client. They work exactly the same other than that.
I was doing that in the past, but I want to make my game faster by not storing models in ReplicatedStorage. With RemoteFunctions, shouldn’t I be able to get these models from ServerStorage?
I’m fairly certain you can’t pass models or parts through the server-client boundary besides using ReplicatedStorage. I’m not 100% certain about that but in my experience you have to use ReplicatedStorage for that to work