I have two scripts to execute/receive the RemoveEvent which will lead to the GUI being copied into the PlayerGui. The first script is a regular script I placed in the workspace, and it's purpose is to fire the client.
local RemoteEvent = game.ReplicatedStorage.GUIStuff game.Players.PlayerAdded:connect(function(player) RemoteEvent:FireClient(player) end)
Below is the local script I have in StarterPlayerScripts and is meant to receive the fired event and clone the ScreenGui called 'Start' and place it into the PlayerGui.
local RemoteEvent = game.ReplicatedStorage.GUIStuff local player = game.Players.LocalPlayer RemoteEvent.OnClientEvent:connect(function() local gui = game.ReplicatedStorage.Start:Clone() if (not player.PlayerGui:FindFirstChild(gui.Name)) then gui.Parent = player.PlayerGui end end)
Through printing tests in the output, I've found that the problem lies somewhere in the second script but I don't know where. Anyone know why?
There doesn't seem to be anything wrong with your script, however I would suggest you make sure the character is loaded first before firing the event, you can do this by adding this function:
player.CharacterAdded:Connect(function(char) end)
Simply add it like this:
local RemoteEvent = game.ReplicatedStorage.GUIStuff game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:Connect(function(char) RemoteEvent:FireClient(player) end) end)
Also Horribilis_Aedrovulf's answer is correct.
You don't need a remote event for this.
game.Players.PlayerAdded:connect(function(player) local gui = game.ReplicatedStorage.Start:Clone() if not (player.PlayerGui:FindFirstChild(gui.Name)) then gui.Parent = player.PlayerGui end end)
Edit: Out of curiosity, what are you trying to do exactly? The ScreenGui if placed in StarterGui is already replicated to PlayerGui automatically?
Everything inside the player's PlayerGui is not replicated to the server or other clients.
You will have to directly clone the assets into their PlayerGui from the server for it to be accessed from the server.
Add the GUI (server):
local players = game:GetService("Players") local function playerAdded(player) local gui = game:GetService("ServerStorage"):WaitForChild("SomeGui"):Clone() gui.Parent = player:WaitForChild("PlayerGui") end players.PlayerAdded:Connect(playerAdded)