This is my scenario:
My game will have hundreds of meshes/parts, which means it will take up a lot of space, as each mesh can occupy several Kb or even Mb, depending on the complexity and texture of each mesh.
This way, to avoid unnecessary data transfer, the user will choose manually a part via GUI (like Minecraft) and only then the part will be loaded.
For that, I’m hosting ALL parts on ServerStorage
.
When the user chooses which part he wants via GUI, I start a RemoteFunction
, like
ReplicatedStorage:WaitForChild("MyRemoteFunction"):InvokeServer(partName)
And inside ServerScriptServer
I have a script with this function which finds this part (all parts are in a folder “MyFolder”) on the ServerStorage and clone it to workspace
:
local part = game.ServerStorage.MyFolder:FindFirstChild(partName)
local partWorkspace = part:Clone()
partWorkspace.Parent = workspace.MyFolder
return partWorkspace
So far so good…
The problem here is: when I clone a part to workspace
, that part will be cloned to ALL players. I don’t want it, once it’s unnecessary because, in my game, there are rooms where only the current player can see his items, therefore there is no need this part to be replicated to all players.
But it seems not to be possible to clone a part via ServerScript only for the current player. Am I right?
At the same time, if I put all these meshes/parts in ReplicatedStorage
, this will be the worst scenario, because the game will transfer ALL the bytes of all parts to all players, causing a communication overhead.
In short, is there a way to clone a part located inside
ServerStorage ONLY for the current player?