Hello.
I’m wondering how would I clone a GUI (or a random brick for example) to a specific player only and if that’s a GUI, it would be visible to the player only in PlayerGui, not the server.
For example, if I used :Clone from server storage to PlayerGui, that GUI would still be visible to the server.
If I put it in ReplicatedStorage for example, anyone could access it.
For buildings, how would I clone them to a client without them being visible to other players?
Well, I know how to clone, but I dont want GUIs to appear to server and for buildings, I don’t want them to appear to other players as the only way I know to store buildings is to put them in Rep. Storage.
Oh okay. You will be able to clone a GUI from the server storage to the players PlayerGui, and only the player that the GUI is cloned into will see that GUI.
Now with the building, to my knowledge, you couldn’t have that in server storage, because you would want a local script to clone the building on the clients side. You would be able to achieve this by moving the building from server storage to replicated storage.
Also, just a note. Anything cloned by a local script is only seen by the player who has the local script, and it will not be seen by the server.
And just in case you have an old game, you would need to turn filter enabled on so that there is a difference between client and server.
Sorry for bumping this thread, but I’m looking forward to the solution without opening a new one.
Are there any other solutions?
TL;DR: for example, how would I make a GUI (surface gui) visible to specific people only (in workspace) without putting it in replicated storage (which would make it accessible to everyone), but rather cloning it from the server side directly to the client side.
You could clone to the Player’s playerGui and make the player set the adornee of the gui, which would solve your issues with other players seeing it (as other players and the server do not see changes made by a different player’s localscripts), however (i don’t know why you wouldn’t want the server to see something) it leaves the second part out, as cloning the Gui into the player’s gui makes it “visible” on the server.
Possibly my instance to network module would help? It lets you send instances that only exist for the server to the client (server => client) or vice versa (client => server), and while it is no where near complete, it is functional. I published it here.
It isn’t optimized nor is it perfect, however it is easy to use and add more instances to the lookup table, so it works fine for things like your use case.
Hopefully this helps, PM me if you have any questions about it.
Clone the GUI, do not parent it, pass it as an argument via a RemoteEvent, let the client make a clone, let the server (after a short delay or after the client makes a clone) destroy its copy, then make the client put its clone in their own PlayerGui.
Is this during when the server starts? If so, some code like this might work:
local GUI = game:GetService("ServerStorage").GUI:Clone()
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
if Player.Name == "PlayerName" or Player.UserId == 12345678 then
GUI.Parent = Player.PlayerGui
end
end)
If this doesn’t fit your case then I don’t really understand your question.
Thank you, but the GUI will still be visible on the server side, but I guess that’s fine. I’ll just use remote events to destroy them from client’s side.