Welcome to the Forums!
Join thousands of other Roblox members with a free account.
Create Forum Account

My code will not put the gui in the players playergui

  • This website was created by Roblox members to replace the official forums (because Roblox shut them down) Join us if you like Roblox!
Status
Not open for further replies.

bluechristmas20181

New Member
Reputation: 0 / 0 / 0
Jul 21, 2020
5
0
1
Roblox
bluechristmas20181
Hello, my code will not put the gui in the players playergui, here is the code:
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)
Help would be appreciated! :)
 

CallMeKY

Moderator
Ultra
Reputation: 6 / 0 / 0
Feb 25, 2018
1,655
76
804
113
Maine, USA
Roblox
CallMeKY
Discord
CallMeKY#5012
Hello, my code will not put the gui in the players playergui, here is the code:
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)
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.

Lua:
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)
 
Status
Not open for further replies.