Overhead GUI not working anymore

I have been coding all my overhead gui’s like this and now all of a sudden it doesnt work anymore??? who knows why or did i make a error or did roblox update their code??

game.Players.PlayerAdded:Connect(function(Player)

	local rep = game:GetService("ReplicatedStorage")
	local char = Player.Character or Player.CharacterAdded:Wait()
	local hum = char:WaitForChild("Humanoid")

	if Player.Name == "IAMHULKSUR" then

		local gui = rep:WaitForChild("Developer"):Clone()
		gui.Parent = char.Head
		gui.Adornee = char.Head
		print("The developer is in the game")

	end

end)
1 Like

A few issues that I noticed surrounding your variables and services setup that I’ve improved and fixed here. Alongside that, your code currently is set to only give the player the nametag the first time they’ve joined, and not on each respawn.

Also an added implementation of a table of developers that you can add who will receive the nametag.

local Players = game:GetService("Players")
local rep = game:GetService("ReplicatedStorage")

local Developers = {"IAMHULKSUR"}

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(char) -- UI Parenting hooked to CharacterAdded to handle player respawns
		if table.find(Developers, Player.Name) then
			local gui = rep:WaitForChild("Developer"):Clone()
			gui.Parent = char.Head
			
			print("The developer is in the game")
		end
	end)
end)

Give it a shot and please report back if you run into any issues. Cheers.

Why such a long code now all of a sudden… It used to work with that script i provided

This code here works however, if i use lua if Player.Name == "IAMHULKSUR" then local gui = rep:WaitForChild("Developer") gui.Parent = char.Head then it dont work, but if i do ```lua
game.Players.PlayerAdded:Connect(function(Player)

local char = Player.Character or Player.CharacterAdded:Wait()
local rep = game:GetService("ReplicatedStorage")
	
	local gui = rep:WaitForChild("Developer"):Clone()
	gui.Parent = game.Workspace:WaitForChild("IAMHULKSUR").Head

end)``` then it works why

When you say “don’t work” while parenting the GUI to char.Head, what exactly happens? Usually when there are issues with instances surrounding parenting, there are errors that tell you where things went wrong. Is the code outputting any errors to your console?

A possible fix may be waiting for the Head object, which can account for minor discrepancies in when certain character instances are available after CharacterAdded.

gui.Parent = char:WaitForChild("Head")

No errors at all nothing. Also tried waitforchild and still doesnt work i dont get it because it used to work exactly the way i coded it the first time and now it doesnt even do it. Like i tried parenting it to the character and it shows in character however, when i put it in character.Head is doesnt even show in the head. i also tried ur script and same thing, doesnt work

Are you still having issues with said script?

Try this

local ServerStorage = game:GetService("ServerStorage")
local Tag = ServerStorage.Tag


game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		
		if player.Name == "IAMHULKSUR" then
			local CloneTag = Tag:Clone()
			local NameTag = CloneTag.NameTag
			local RankTag = CloneTag.RankTag


			CloneTag.Parent = char.Head

			NameTag.Text = player.Name
		else
			return print("Player not in-game")
		end
	end)
end)