! | Group rank & leaderstat overhead GUI

Goal: The overhead GUI should look like this: (the knife is the kill count)
image

Script:

local overhead = game:GetService("ServerStorage"):WaitForChild("OverheadGuiObject")

game.Players.PlayerAdded:Connect(function(player)
	
	local overheadClone = overhead:Clone()
	local leaderstat = player.leaderstats:FindFirstChild('Kills')
	
	local character = player.Character or player.CharacterAdded:Wait()
		overheadClone:FindFirstChild("Name").Text = player.Name
		overheadClone.Rank.Text = player:GetRoleInGroup(5127121)
	
	player.leaderstats:GetPropertyChangedSignal('Kills'):Connect(function()
		overheadClone.Kills.Text = "🔪".. player.leaderstats('Kills').Value
	end)
		
		
		overheadClone.Parent = character.Head
end)

Issues:
The overhead does not appear.

It used to appear before I added the part to display the kill count.

What I would do personally with this, is to have a function to actually create the nametag and use the character, e.g function createTag(character), and then proceed as you usually would. Then once they’ve entered the game, have the over head gui in a CharacterAdded function, an example would be below:

game.Players.PlayerAdded:Connect(function(player)
     player.CharacterAdded:Connect(function(character)
          createTag(character)
     end)

     if player.Character then -- sometimes player.CharacterAdded doesn't load when a player first joins
         createTag(player.Character)
     end
end)
1 Like
local Storage = game:GetService("ServerStorage")
local Players = game:GetService("Players")

local overhead = Storage:FindFirstChild("OverheadGuiObject")


Players.PlayerAdded:Connect(function(player)
	player.CharacterAppearanceLoaded:Connect(function(Character)
		local overheadClone = overhead:Clone()
		
		overheadClone:FindFirstChild("Name").Text = player.Name
		local success1,result1 = pcall(function()
			return player:GetRoleInGroup(5127121)
		end)
		if success1 then
			overheadClone.Rank.Text  =result1
		end
		
		player.leaderstats.Kills.Changed:Connect(function()
			overheadClone.Kills.Text = "🔪".. player.leaderstats.Kills.Value
		end)

		overheadClone.Parent = Character:FindFirstChild("Head")
	end)
end)
1 Like