Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why the is not cloning the Gui into PlayerGui?

Here is the code:

local gui = script.ScreenGui

game:GetService("Players").PlayerAdded:Connect(function(player) if player == "SwordChin" then for i,v in pairs(game.Players:GetChildren()) do gui:Clone().Parent = v.PlayerGui end end end)

2 comments

1

Player is a player object, not a string

0

you can check if the player's name is "SwordChin" instead if the player is "SwordChin"

1 answer

✓ Accepted answer

Try something like this:

local gui = script.ScreenGui
local players = game.Players

local function onPlayerAdded(player) --Separate functions for clarity
	if player.UserId == 640603301 then  --Use the UserId instead of names, as that can never be changed
		local playerList = players:GetChildren()
		for count,player in ipairs(playerList) do  --Use ipairs(). Also, properly naming variables is important
			gui:Clone().Parent = player.PlayerGui  
		end  
	end  
end

players.PlayerAdded:Connect(onPlayerAdded)

This should work. Hope I helped :D

3 comments

0

Thank you! Was just to change the player by player.Name,but thank you

0

No problem! I'm glad I helped. Also, can you Accept this answer?

0

By all means

This discussion is preserved as it was. New answers, comments, and votes are closed.