Roleplay name scripts suddenly broken?

I’ve used the same set of scripts for my roleplay games to give the players customizable names and bios for a while. Suddenly, today, they broke and return attempt to index nil with FindFirstChild.

There are multiple of these scripts that work in tandem, but the only two that matter are GiveTitle and ChangeScript.

GiveTitle:
This gives the player the BillboardGui that their name and bio will be in.

local Players = Game:GetService("Players")

local function OnPlayerAdded(Player)
	local function OnCharacterAdded(Character)
		if not Player:HasAppearanceLoaded() then
			Player.CharacterAppearanceLoaded:Wait()
		end

		local Head = Character:WaitForChild("Head")

		local nameGui = Instance.new("BillboardGui")
		nameGui.StudsOffset = Vector3.new(0, 3, 0)
		nameGui.Size = UDim2.new(0, 200, 0, 50)
		nameGui.Name = "BioGui"
		nameGui.Adornee = Head
		nameGui.Parent = Head
		nameGui.MaxDistance = 100

		local nameLabel = Instance.new("TextLabel")
		
		nameLabel.Text = " "
		nameLabel.TextScaled = true
		nameLabel.TextWrapped = true
		nameLabel.Size = UDim2.new(.5, 100, 0, 25)
		nameLabel.BackgroundTransparency = 1
		nameLabel.TextColor3 = Color3.new(255, 255, 255)
		nameLabel.Font = 13
		nameLabel.TextStrokeColor3 = Color3.new(0, 0, 0)
		nameLabel.TextStrokeTransparency = .5
		nameLabel.Name = "BioLabel"
		nameLabel.Parent = nameGui
	end

	Player.CharacterAdded:Connect(OnCharacterAdded)
end

Players.PlayerAdded:Connect(OnPlayerAdded)

ChangeTitle:
This changes the text of the BillboardGui above to whatever the player inputs.



remoteEvent.OnServerEvent:Connect(function(plr, name)


	local char = plr.Character or plr.CharacterAdded:Wait()


	local filteredName = game:GetService("TextService"):FilterStringAsync(name, plr.UserId) 

	local filteredNameAsString = filteredName:GetNonChatStringForBroadcastAsync() 


	local nameGui = char.Head:FindFirstChild("BioGui")

	local nameLabel = nameGui:FindFirstChild("BioLabel")


	nameLabel.Text = filteredNameAsString   
end)

This worked perfectly fine yesterday! Changing FindFirstChild to WaitForChild didn’t work either, instead returning Infinite yield possible on 'Workspace.ControlCoreAngel.Head:WaitForChild("BioGui"), implying BioGui never gets made to begin with.

I suspect Roblox updating broke my stuff again. Help’s appreciated, I don’t see how this isn’t working.

Do you see the nametag above your character’s head? If you do, could you go to the server’s POV and send a screenshot of the character’s head’s children?

The nametag doesn’t spawn in. Even manually inputting text here:
nameLabel.Text = " "
does nothing.

Ok, I looked closer into the script, and I believe the problem is right here.

local Players = game:GetService("Players")

No dice. Returns the same errors as before.

Really? It works perfectly fine for me. The nametag is created inside of the head.
image

local Players = game:GetService("Players")

local function OnPlayerAdded(Player)
	local function OnCharacterAdded(Character)
		if not Player:HasAppearanceLoaded() then
			Player.CharacterAppearanceLoaded:Wait()
		end

		local Head = Character:WaitForChild("Head")

		local nameGui = Instance.new("BillboardGui")
		nameGui.StudsOffset = Vector3.new(0, 3, 0)
		nameGui.Size = UDim2.new(0, 200, 0, 50)
		nameGui.Name = "BioGui"
		nameGui.Adornee = Head
		nameGui.Parent = Head
		nameGui.MaxDistance = 100

		local nameLabel = Instance.new("TextLabel")

		nameLabel.Text = " "
		nameLabel.TextScaled = true
		nameLabel.TextWrapped = true
		nameLabel.Size = UDim2.new(.5, 100, 0, 25)
		nameLabel.BackgroundTransparency = 1
		nameLabel.TextColor3 = Color3.new(255, 255, 255)
		nameLabel.Font = 13
		nameLabel.TextStrokeColor3 = Color3.new(0, 0, 0)
		nameLabel.TextStrokeTransparency = .5
		nameLabel.Name = "BioLabel"
		nameLabel.Parent = nameGui
	end

	Player.CharacterAdded:Connect(OnCharacterAdded)
end

Players.PlayerAdded:Connect(OnPlayerAdded)

My game’s mod just reported they’re working again.
Just a Roblox issue, it seems.

EDIT: Nevermind, it’s only selectively working. It works for other people, just not me for some reason.
EDIT 2: It appears the saved outfits feature of the character customizer we use is what’s breaking it. Hm.

Considering it seems to be a problem of our character customizer (I believe saved outfits destroy the player’s Character), I’ve tried a new method:

local Players = game:GetService("Players")

while true do
for _,player in ipairs(Players:GetPlayers()) do
	local Character = player.Character
		local Head = Character:WaitForChild("Head")
		
		if Head.nameGui == nil and Head.nameLabel == nil then
			local nameGui = Instance.new("BillboardGui")
			nameGui.StudsOffset = Vector3.new(0, 3, 0)
			nameGui.Size = UDim2.new(0, 200, 0, 50)
			nameGui.Name = "BioGui"
			nameGui.Adornee = Head
			nameGui.Parent = Head
			nameGui.MaxDistance = 100
			
			local nameLabel = Instance.new("TextLabel")
			nameLabel.Text = " "
			nameLabel.TextScaled = true
			nameLabel.TextWrapped = true
			nameLabel.Size = UDim2.new(.5, 100, 0, 25)
			nameLabel.BackgroundTransparency = 1
			nameLabel.TextColor3 = Color3.new(255, 255, 255)
			nameLabel.Font = 13
			nameLabel.TextStrokeColor3 = Color3.new(0, 0, 0)
			nameLabel.TextStrokeTransparency = .5
			nameLabel.Name = "BioLabel"
			nameLabel.Parent = nameGui
		end
	end
end

However this doesn’t work either.

I hate to bug, @0_1195, but considering you’re the maker of the Avatar Editor I use, do you have any thoughts or suggestions?

Use AvatarEditorServer.HumanoidDescriptionChanged to detect when the player changes their avatar and add the BillboardGui back.

Try this

local Players = Game:GetService("Players")

local function OnPlayerAdded(Player)
        wait()
		if  Player:HasAppearanceLoaded() then
		local Head = Character:WaitForChild("Head")
		local nameGui = Instance.new("BillboardGui")
		nameGui.StudsOffset = Vector3.new(0, 3, 0)
		nameGui.Size = UDim2.new(0, 200, 0, 50)
		nameGui.Name = "BioGui"
		nameGui.Adornee = Head
		nameGui.Parent = Head
		nameGui.MaxDistance = 100

		local nameLabel = Instance.new("TextLabel")
		
		nameLabel.Text = " "
		nameLabel.TextScaled = true
		nameLabel.TextWrapped = true
		nameLabel.Size = UDim2.new(.5, 100, 0, 25)
		nameLabel.BackgroundTransparency = 1
		nameLabel.TextColor3 = Color3.new(255, 255, 255)
		nameLabel.Font = 13
		nameLabel.TextStrokeColor3 = Color3.new(0, 0, 0)
		nameLabel.TextStrokeTransparency = .5
		nameLabel.Name = "BioLabel"
		nameLabel.Parent = nameGui
        else
        Player.CharacterAppearanceLoaded:Wait()
		local Head = Character:WaitForChild("Head")
		local nameGui = Instance.new("BillboardGui")
		nameGui.StudsOffset = Vector3.new(0, 3, 0)
		nameGui.Size = UDim2.new(0, 200, 0, 50)
		nameGui.Name = "BioGui"
		nameGui.Adornee = Head
		nameGui.Parent = Head
		nameGui.MaxDistance = 100

		local nameLabel = Instance.new("TextLabel")
		
		nameLabel.Text = " "
		nameLabel.TextScaled = true
		nameLabel.TextWrapped = true
		nameLabel.Size = UDim2.new(.5, 100, 0, 25)
		nameLabel.BackgroundTransparency = 1
		nameLabel.TextColor3 = Color3.new(255, 255, 255)
		nameLabel.Font = 13
		nameLabel.TextStrokeColor3 = Color3.new(0, 0, 0)
		nameLabel.TextStrokeTransparency = .5
		nameLabel.Name = "BioLabel"
		nameLabel.Parent = nameGui
		end
	end
end

Players.PlayerAdded:Connect(OnPlayerAdded)

[/quote]

I’m still rather new at scripting, could you perhaps provide an example?
Linking one script’s function to another is something I’m still not terribly sure how to do.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local AvatarEditor = ReplicatedStorage.AvatarEditor
local AE = require(ServerStorage.AvatarEditorServer)

AE.HumanoidDescriptionChanged:Connect(function(player: Player, description: HumanoidDescription)
	local character = player.Character
	local head = character.Head

	-- insert BillboardGui
end)

Sadly doesn’t work, neither when put in its own Script nor within the original GiveTitle.

New script:

local ServerStorage = game:GetService("ServerStorage")

local AvatarEditor = ReplicatedStorage.AvatarEditor
local AE = require(ServerStorage.AvatarEditorServer)

AE.HumanoidDescriptionChanged:Connect(function(player: Player, description: HumanoidDescription)
	local character = player.Character
	local Head = character.Head

		local nameGui = Instance.new("BillboardGui")
		nameGui.StudsOffset = Vector3.new(0, 3, 0)
		nameGui.Size = UDim2.new(0, 200, 0, 50)
		nameGui.Name = "BioGui"
		nameGui.Adornee = Head
		nameGui.Parent = Head
		nameGui.MaxDistance = 100

		local nameLabel = Instance.new("TextLabel")
		
		nameLabel.Text = " "
		nameLabel.TextScaled = true
		nameLabel.TextWrapped = true
		nameLabel.Size = UDim2.new(.5, 100, 0, 25)
		nameLabel.BackgroundTransparency = 1
		nameLabel.TextColor3 = Color3.new(255, 255, 255)
		nameLabel.Font = 13
		nameLabel.TextStrokeColor3 = Color3.new(0, 0, 0)
		nameLabel.TextStrokeTransparency = .5
		nameLabel.Name = "BioLabel"
		nameLabel.Parent = nameGui

end)

What does not work? I just tested it and it created the BillBoardGui under my character’s Head when I changed my avatar.

It doesn’t appear to be creating the GUIs at all, the same issue as my first post…

Even creating a while true do doesn’t create the GUIs. I’m stumped.

local Players = game:GetService("Players")

local function OnPlayerAdded(Player)
	local function OnCharacterAdded(Character)
		if not Player:HasAppearanceLoaded() then
			Player.CharacterAppearanceLoaded:Wait()
		end
	local Head = Character.Head

		while true do
			if Head.NameGui == nil then
				local nameGui = Instance.new("BillboardGui")
				nameGui.StudsOffset = Vector3.new(0, 4, 0)
				nameGui.Size = UDim2.new(0, 200, 0, 50)
				nameGui.Name = "NameGui"
				nameGui.Adornee = Head
				nameGui.Parent = Head
				nameGui.MaxDistance = 100

				local nameLabel = Instance.new("TextLabel")
				nameLabel.Text = " "
				nameLabel.TextScaled = true
				nameLabel.TextWrapped = true
				nameLabel.Size = UDim2.new(.5, 100, 0, 25)
				nameLabel.BackgroundTransparency = 1
				nameLabel.Font = 13
				nameLabel.TextStrokeColor3 = Color3.new(0, 0, 0)
				nameLabel.TextStrokeTransparency = 0.5
				nameLabel.Name = "NameLabel"
				nameLabel.Parent = nameGui
			end
		end
	end
end

Instead of creating a new object why not just make a standalone billboard gui in serverstorage then have it clone to character head on CharacterAdded?
Also is that the entire script? Something might be yielding PlayerAdded.

I wasn’t the original developer of this script, a friend of mine was, so I don’t know his reasoning for creating one as opposed to cloning one.

It works perfectly fine, it’s just that it’s rather incompatible with 0_1195’s avatar editor which I use pretty religiously (it’s a damn good resource, man), and it messes with the player’s Character quite a bit.

Script in ServerScriptService.

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

local AvatarEditor = ReplicatedStorage.AvatarEditor
local AE = require(ServerStorage.AvatarEditorServer)

local function createBillboard()
	local nameGui = Instance.new("BillboardGui")
	nameGui.StudsOffset = Vector3.new(0, 3, 0)
	nameGui.Size = UDim2.new(0, 200, 0, 50)
	nameGui.Name = "BioGui"
	nameGui.MaxDistance = 100

	local nameLabel = Instance.new("TextLabel")
	nameLabel.Text = " "
	nameLabel.TextScaled = true
	nameLabel.TextWrapped = true
	nameLabel.Size = UDim2.new(.5, 100, 0, 25)
	nameLabel.BackgroundTransparency = 1
	nameLabel.TextColor3 = Color3.new(255, 255, 255)
	nameLabel.Font = 13
	nameLabel.TextStrokeColor3 = Color3.new(0, 0, 0)
	nameLabel.TextStrokeTransparency = .5
	nameLabel.Name = "BioLabel"
	nameLabel.Parent = nameGui

	return nameGui
end

local function adorneToCharacter(character: Model)
	local head = character.Head
	
	if head:FindFirstChild("BioGui") then
		return
	end
	
	local billboard = createBillboard()
	billboard.Adornee = head
	billboard.Parent = head
end

local function playerAdded(player: Player)
	local function characterAdded(character: Model)
		adorneToCharacter(character)
	end

	if player.Character then
		characterAdded(player.Character)
	end

	player.CharacterAdded:Connect(characterAdded)
end

Players.PlayerAdded:Connect(playerAdded)

AE.HumanoidDescriptionChanged:Connect(function(player: Player, description: HumanoidDescription)
	task.wait(1) -- HumanoidDescriptionChanged fires before actually applying the HumanoidDescription.....
	local character = player.Character
	adorneToCharacter(character)
end)

At this point if it does not work then there must be something else causing the problem.

It seems Roblox have changed how HumanoidDescriptions work from the last time I played with them. When applying the HumanoidDescription it only changes the relevant parts that need to be changed. Meaning that if you change a body part, like an arm, only the arm parts update instead of redrawing the whole character.

Just to let you know, if someone changes their roleplay name and then change their avatar, the billboard will reset to whatever text you have set by default in the script. Unless you have a way around this, people will have to set their roleplay names every time they change their avatar.

1 Like

It WOOOORKS! Thank you so much for your help, you really didn’t have to do this and yet still did.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.