I made a script that clones a billboardgui from lighting and puts it inside the player's head when they join. Players can also use "!toggle" to turn it on and off. So far the script works to change the text of the GUI to their name and role in the group, but when players not in the group join, it just says "Label". I have an else statement to display a player's name, and then say "Guest" after if they aren't in the group, but it doesn't work. Any help would be appreciated. Note: There were no output errors.

local billboard = game.Lighting.BillboardGui:Clone()
local function giverole(p)
	local char = p.Character
	local role = p:GetRoleInGroup(5629879)
	local billboard = game.Lighting.BillboardGui:Clone()
	billboard.Parent = char.Head
	wait(0.1)
	if p:IsInGroup(5629879) then 
			billboard.TextLabel.Text = p.Name ..", " .. role 

	else 
			billboard.TextLabel.Text = p.Name ..", Guest"
	end
		local toggled = false
		p.Chatted:Connect(function(msg)
			if msg:sub(1,10) == "!toggle" and toggled == false then
				toggled = true
				char.Head.BillboardGui.Enabled = false
			elseif msg:sub(1,10) == "!toggle" and toggled == true then
					toggled = false
					char.Head.BillboardGui.Enabled = true	
				end
 
		end)
end
game.Players.PlayerAdded:Connect(giverole)
game.Players.PlayerAdded:Connect(function(p)
	p.Changed:Connect(function (property)
		if (property == "Character") then
		       giverole(p)
		end
	end)
	end)
	



1 comment

0

lol pls help