Passing instances from server storage to client with remote function

  1. What do you want to achieve?

Hi guys!, I Planned to make voting system but the thumbnails I want to make the map models using viewport frames.

  1. What is the issue?

Is it possible to pass instances from server storage to client with remote function?

  1. What solutions have you tried so far?

If I’ll put models on replicated storage clients will get access to it as well, I don’t want them to get access on it.

I hope anyone can answer my question. :slightly_smiling_face:

1 Like

No it is not possible. The entire purpose of ServerStorage is to store content only on the server. For it to later be used.

You will be cloning them out of ServerStorage and into the Workspace anyways, so not sure why this is a concern.

1 Like

I’ll clone the map only when the voting has finished. There’s no other way to pull this off?

30 characters.

1 Like

It has to exist on the server and the client.
Sending an instance from ServerStorage to your client won’t work, the instance will be nil.

1 Like

You should put your maps in ReplicateStorare, as it can be downloaded by the client in runtime.
They can steal your maps anyways, once they are parented to workspace.

Stealing maps is a common thing, you shouldn’t worry.
Simply report the user that stole your maps to Roblox, and they will deal with it.

So I had to put it on replicated storage to get copy of the map?

True actually, doesn’t it just send a reference to the object? nvm. but if you sent instances from any Server container to the client as keys inside of a dictionary, they don’t become nil, If I recall correctly, the key becomes something like <Instance> [name of the instance here].

To render ViewportFrames the client needs to have access to all parts in them, so you should put it in ReplicatedStorage

Does it accessible by remote function that fired by server on clients?

Yeah as everyone else said, you need to do that. Another advantage is inserting the map to the viewport happens faster, because if you were do it from the server (I’m talking theoretically here, replicating instances from server to client isn’t possible unless you do some serialization), you would need to replicate the map, and put it in the viewport, and replicating takes sometime of course. But in the client, it’s already loaded there, you just copy it and insert it.

Instance[Instance] = Instance

Ummmm… is this the right format?

Not really sure, but it’s a string, it’s not an instance, you can’t do anything with it. It is worth testing, try to send an instance from the client to the server and see the result.

RemoteFunction:OnServerInvoke = function(player)
local Data = {}
Data[Instance.Name] = Instance
return Data
end

Does this will worked?

nil means that there is nothing there. It will return nil because the client cannot access it.
It has to exist on both server and client.

Example:
Server

local Event = game:GetService('ReplicatedStorage').Event
local instance = game:GetService('ServerStorage').instance

Event:FireAllClients(instance, instance.Name)

Client

local Event = game:GetService('ReplicatedStorage'):WaitForChild('Event')

Event.OnClientEvent:Connect(function(Object, ObjectName)
	print(type(Object)) --> nil
	print(ObjectName) --> instance, because it is a string
end)

I’m using remote function in this case, what’s the purpose of string that passed to client?

There can be a purpose if you want it to be, but you cannot send instances, as I showed you above.
You’ll need to find another solution that both the client and server has access to.

I said if it’s sent as a key inside of a dictionary, if you sent something like

Event:FireAllClients({[instance] = true})

and looped through the dictionary in the client

Event.OnClientEvent:Connect(function(dict)
	for i, v in pairs(dict) do 
       print(i, v) -- <instance> something true, I think
    end
end)

perhaps I’m wrong about this.

And it is possible to send instances after doing some work.

The index will be nil, value will be true
In other words: nil = true.

Did you try the code? If so, that interesting. I remember getting similar results, unless it’s something else.

I’m no good at HTTPS service. 30 characters