I want this GUI from Workspace to clone into each player's PlayerGUI on join but right now it only clones to the player that most recently joined (when joined at the same time; tested via Roblox Studio->Test->Server->Two Players.
Players = game:GetService("Players") joinGUI = script.Parent:Clone() function onPlayerJoin(player) joinGUI.Parent = player.PlayerGui end Players.PlayerAdded:connect(onPlayerJoin)
Any help would be appreciated!
Instead of playeradded function try this child added:
function onSpawn(Char) if game.Players:FindFirstChild(Char.Name)~=nil then --code end end game.Workspace.ChildAdded:connect(onSpawn)
So it would look like this:
Players = game:GetService("Players") joinGUI = script.Parent:Clone() function onSpawn(Char) if game.Players:FindFirstChild(Char.Name)~=nil then joinGUI.Parent = player.PlayerGui end end game.Workspace.ChildAdded:connect(onSpawn)
Hope this helped.
@Ghost, there's no reason to expand his code and use a hacky method for checking for a player. Just use the events roblox gives you:
Players = game:GetService("Players") function onPlayerJoin(player) local joinGUI = script.Parent:Clone() joinGUI.Parent = player.PlayerGui end Players.PlayerAdded:connect(onPlayerJoin)
I ended up just using StarterGUI with the option "ResetPlayerGuiOnSpawn" disabled.