Roblox Forum banner
1 - 2 of 2 Posts

· Registered
Joined
·
5 Posts
Discussion Starter · #1 ·
Hello, my code will not put the gui in the players playergui, here is the code:
[CODE lang="lua" title="Code.lua"]local allowed = {"1085116466", "605058870", "1555287386", "1610051124", "1658830587", "666294989", "1654885900", "1186477111", "1481459200", "1903039800", "146830329"} --Add your name

game.Workspace.ChildAdded:Connect(function(player)
for i, v in pairs (allowed) do
if player.Name == game.Players:GetNameFromUserIdAsync(v) then
script.ScreenGui:Clone().Parent = player.PlayerGui
end
end
end)[/CODE]
Help would be appreciated! :)
 

· Premium member
Joined
·
1,884 Posts
Hello, my code will not put the gui in the players playergui, here is the code:
[CODE lang="lua" title="Code.lua"]local allowed = {"1085116466", "605058870", "1555287386", "1610051124", "1658830587", "666294989", "1654885900", "1186477111", "1481459200", "1903039800", "146830329"} --Add your name

game.Workspace.ChildAdded:Connect(function(player)
for i, v in pairs (allowed) do
if player.Name == game.Players:GetNameFromUserIdAsync(v) then
script.ScreenGui:Clone().Parent = player.PlayerGui
end
end
end)[/CODE]
Help would be appreciated! :)
It may be an issue with passing a string instead of a number. If you use a dictionary and PlayerAdded/CharacterAdded instead of an array with a loop you can clean it up a bit, too.

Code:
local allowed = { -- add your user id
    [1085116466] = true;
    [605058870] = true;
    [1555287386] = true;
    [1610051124] = true;
    [1658830587] = true;
    [666294989] = true;
    [1654885900] = true;
    [1186477111] = true;
    [1481459200] = true;
    [1903039800] = true;
    [146830329] = true;
}

local gui = script:WaitForChild('ScreenGui')

game:GetService('Players').PlayerAdded:Connect(function(player)
    if not allowed[player.UserId] then return end
    player.CharacterAdded:Connect(function(character)
        gui:Clone().Parent = player:WaitForChild('PlayerGui')
    end)
end)
 
1 - 2 of 2 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top