Team-based Overhead Rank and Name GUI

Hello!

So I was recently doing solo work on a game of mine. For obvious reasons, I wanted to add an overhead GUI that basically shows your name and rank instead of the normal ROBLOX username and health. Thing is, it has to be bound to a group, or at least the script a friend of mine made for me has to. I am not experienced with scripting in any way, nor am I a scripter, and here’s the thing. I don’t want the overhead name and rank to be bound to a ROBLOX group.

Instead, I want those on “Team A” to have their overhead rank to be “Team A”. Basically, their overhead rank is dependant on what team they are on, and it updates to that rank accordingly once someone is put on that team and respawned. One thing I would also like to do with the script is have “Team A” have like, no name. I want to have it be full blocks or question marks or something, but as mentioned before, I’m not a scripter, nor am I experienced with scripting. I know the very basic basics of scripting. You may consider it a bad move to be making a game all on my own with only basic scripting experience, but here’s the thing, the game requires only basic scripting so far.

I don’t know what exactly from the script you want me to provide, the entire script or just a fraction, so let me know what I should provide. I have a custom overhead GUI, however, as mentioned, it has to be bound to a group. Thank you in advance!

If you don’t mind, send the script of whatever your friend sent. I will be able to tamper around with it.

1 Like

or if you want, I can premake one for yah, and you can just try to understand yourself.

1 Like
local groupId = 6986278

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local GuiClone = script.OverheadGui:Clone()
		GuiClone.Parent = Character.Head

		local Info = GuiClone.Info

		local PlayerRank = Player:GetRoleInGroup(groupId)
		Info.Text = Player.Name .. "\n  " .. PlayerRank
	end)
end)

This is the script, it’s obviously designed for group-binding use but eh. The group ID provided is for a cafe group of mine which this was originally to be used for. But obviously, I don’t want to bind it with the group.

Well uh, that’s up to you to decide.

Try this if you would want to put the player’s team name show up in the overhead

local function changeText(Player, infoText)
	local teamName = Player.Team.Name
	
	if teamName == "Team A" then
		teamName = "?????"
	end

	infoText.Text = Player.Name.."\n  "..teamName
end

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local GuiClone = script.OverheadGui:Clone()
		GuiClone.Parent = Character.Head

		local Info = GuiClone.Info
		changeText(Player, Info)
		
		Player:GetPropertyChangedSignal("Team"):Connect(function()
			if Info then
				changeText(Player, Info)
			end
		end)
	end)
end)

I added the extra feature of it having the team color as well, if you don’t want it, then delete the last line. (Info.Text.Color3 = Player.TeamColor.Color)

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local GuiClone = script.OverheadGui:Clone()
		GuiClone.Parent = Character.Head

		local Info = GuiClone.Info

		local PlayerTeam = Player.Team.Name
		Info.Text = Player.Name.."\n"..PlayerTeam
        Info.Text.Color3 = Player.TeamColor.Color
	end)
end)

That should work, let me know otherwise!

1 Like

Remove groupId and make PlayerRank equal to Player.Team.Name.