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)
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)
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
Thank you! Was just to change the player by player.Name,but thank you
No problem! I'm glad I helped. Also, can you Accept this answer?
By all means
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Player is a player object, not a string
you can check if the player's name is "SwordChin" instead if the player is "SwordChin"