So let's say I have a textlabel in Player 1 StarterGui and I want to clone it and put it specifically in Player 2's StarterGui, how would I go about scripting and accessing Player 2's StarterGui or am I trying to script this the wrong way?
So how you would do this is simple, though you'd have to use client-server-client communication.
First, create a RemoteFunction
in ReplicatedStorage
.
Then, you want to make a Script
in ServerScriptService
.
From there you'll go into the script and type the following:
local repStorage = game:GetService("ReplicatedStorage") local remoteFunction = repStorage.RemoteFunction remoteFunction.OnServerInvoke = function(player1, player2, gui) gui:Clone().Parent = player2.PlayerGui end
Then, you'll make a LocalScript
inside of the ScreenGui
you're trying to clone.
Inside of the LocalScript
, you will put this.
local repStorage = game:GetService("ReplicatedStorage") local remoteFunction = repStorage.RemoteFunctionprint("Hello world!") local guiObject = script.Parent remoteFunction:InvokeServer("PlayerNameHere", guiObject)
This should work fine. The InvokeServer
function takes a Player's name as an argument, and the gui you're trying to clone.
If you need any more help, let me know.