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

Custom Player Name Gui doesnt work for non-group members?

The script works fine for players who are in the group, but players who are not in the group...the gui doesnt even appear. No errors at all.

function plrjoined(plr)
	plr.CharacterAdded:connect(function(char)
	local Rank = plr:GetRankInGroup(3569513)
	local Role = plr:GetRoleInGroup(3569513)
	local GUI = script.BillboardGui
	if plr:IsInGroup(3569513) then
		GUI:Clone().Parent = char.Head
		local playerGUI = char.Head.BillboardGui
		playerGUI.GUINAME.Text = plr.Name .. "|" .. Role
		playerGUI.GUINAME.TextColor = plr.TeamColor
		playerGUI.Adornee = char.Head
	if not plr:IsInGroup(3569513) then
		GUI:Clone().Parent = char.Head
		local playerGUI = char.Head.BillboardGui
		playerGUI.GUINAME.Text = plr.Name .. "|C-" .. math.random(10000,90000)
		playerGUI.GUINAME.TextColor = plr.TeamColor
		playerGUI.Adornee = char.Head
	end
	end
	end)
end

game.Players.ChildAdded:connect(plrjoined)

1 comment

0

line 12 to an else statement

1 answer

It will not work because your second if not statement is inside your first statement. I would just change line 12 to else and remove one of the ends after those ifs and it will deal with it.

function plrjoined(plr)
    plr.CharacterAdded:connect(function(char)
    local Rank = plr:GetRankInGroup(3569513)
    local Role = plr:GetRoleInGroup(3569513)
    local GUI = script.BillboardGui
    if plr:IsInGroup(3569513) then
        GUI:Clone().Parent = char.Head
        local playerGUI = char.Head.BillboardGui
        playerGUI.GUINAME.Text = plr.Name .. "|" .. Role
        playerGUI.GUINAME.TextColor = plr.TeamColor
        playerGUI.Adornee = char.Head
    else
        GUI:Clone().Parent = char.Head
        local playerGUI = char.Head.BillboardGui
        playerGUI.GUINAME.Text = plr.Name .. "|C-" .. math.random(10000,90000)
        playerGUI.GUINAME.TextColor = plr.TeamColor
        playerGUI.Adornee = char.Head
    end
    end)
end

game.Players.ChildAdded:connect(plrjoined)

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