Please help this code is just for some reason not working

so0ooo for some reason it works in studio but not in game a roleplay name changer


heres my code


local toClone = game.ReplicatedStorage.PlayerOverhead
local textServ = game:GetService("TextService")


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

	local rpData = Instance.new("Folder")
	rpData.Name = "RPData"

	local rpName = Instance.new("StringValue")
	rpName.Name = "RPName"
	rpName.Parent = rpData


	rpData.Parent = plr


	plr.CharacterAdded:Connect(function(char)
		local cloned = toClone:Clone()

		cloned.Parent = char.Head
		if(plr.RPData.RPName.Value ~= "") then
			cloned.TextLabel.Text = plr.RPData.RPName.Value

		else
			cloned.TextLabel.Text = plr.Name
		end
	end)

	plr.RPData.RPName.Changed:Connect(function()
		plr.Character.Head.PlayerOverhead.TextLabel.Text = plr.RPData.RPName.Value
	end)
end)


game.ReplicatedStorage.ChangeRPName.OnServerEvent:Connect(function(plr, name)

	local filteredObject
	local filteredText

	local success, err = pcall(function()
		filteredObject = textServ:FilterStringAsync(name, plr.UserId)
	end)

	if(success) then
		local complete, failed = pcall(function()
			filteredText = filteredObject:GetNonChatStringForBroadcastAsync()
		end)

		if(complete) then
			plr.Character.Head.PlayerOverhead.TextLabel.Text = filteredText
		end
	end
end)
script.Parent.MouseButton1Click:Connect(function()
	local text = script.Parent.Parent.TextBox.Text

	if(text ~= "") then
		print("Firing")
		game.ReplicatedStorage.ChangeRPName:FireServer(text)
	end
end)

please send a fixed version of what’s being buggy and please tell me what i missed
because i have been trying different things for days and nothing is working the studio version works but the in game version dosent i am just so confused

You have to wait for the Character to be parented to workspace Roblox will auto delete the billboard GUI since the character is still not parented yet when you parented the UI.

You can swap CharacterAdded to CharacterAppearanceLoaded and issue will be solved, or you can wait for it to be in workspace another way though the first method would be perfect.

plr.CharacterAppearanceLoaded:Connect(function(char)

trying it right now fingers are crossed

Did you update the game or…?

IT WORKED THANK YOU also I am trying to figure how to remove the filter because i am only making it for my sister and her friends to rp on and the filter will just be an incovience for them and nobody else will be playing it if you could help with that too

oh wait wrong person oh well dosent matter

I guess I see the point, but still, to be safe make sure you make at least a slight working filter, or who knows if somebody swears. Your account and the person who swore, the accounts might be in danger, so yeah! Good job on finding the issue.

Haha, no just give them the solution, they deserve it.

k lol they asked me to do it for free sooo yeah

i guess i don’t really care that much

The code dosent work anymore? for some odd reason the code dosent work at all in game anymore

in studio:


in game:

I found to culprit but dont know how to fix it, it’s this line of code for blocky bodies do you know why it is causing it to bug please help


local Players = game.Players

function PlayerJoined(Player)
	local function RemoveMeshes(Character)
		local Humanoid = Character:WaitForChild("Humanoid")
		wait()
		local CurrentDescription = Humanoid:GetAppliedDescription()

		CurrentDescription.Head = 0
		CurrentDescription.Torso = 0
		CurrentDescription.LeftArm = 0
		CurrentDescription.RightArm = 0
		CurrentDescription.LeftLeg = 0
		CurrentDescription.RightLeg = 0
		Humanoid:ApplyDescription(CurrentDescription)
	end
	Players.CharacterAdded:Connect(RemoveMeshes)
end

Players.PlayerAdded:Connect(PlayerJoined)

Try changing the code to this, this waits for everything to fully load.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local toClone = ReplicatedStorage:WaitForChild("PlayerOverhead")
local textServ = game:GetService("TextService")


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

	local rpData = Instance.new("Folder", plr)
	rpData.Name = "RPData"

	local rpName = Instance.new("StringValue", rpData)
	rpName.Name = "RPName"


	plr.CharacterAdded:Connect(function(char)
		local cloned = toClone:Clone()

		cloned.Parent = char:WaitForChild("Head")
		if (plr.RPData.RPName.Value ~= "") then
			cloned:WaitForChild("TextLabel").Text = plr.RPData.RPName.Value

		else
			cloned:WaitForChild("TextLabel").Text = plr.Name
		end
	end)

	plr.RPData.RPName.Changed:Connect(function()
        if game.Workspace:FindFirstChild(plr.Name) then
            plr.Character:WaitForChild("Head"):WaitForChild("PlayerOverhead"):WaitForChild("TextLabel").Text = plr.RPData.RPName.Value
        end
	end)
end)


ReplicatedStorage:WaitForChild("ChangeRPName").OnServerEvent:Connect(function(plr, name)

	local filteredObject
	local filteredText

	local success, err = pcall(function()
		filteredObject = textServ:FilterStringAsync(name, plr.UserId)
	end)

	if(success) then
		local complete, failed = pcall(function()
			filteredText = filteredObject:GetNonChatStringForBroadcastAsync()
		end)

		if (complete) and game.Workspace:FindFirstChild(plr.Name) then
			plr.Character:WaitForChild("Head"):WaitForChild("PlayerOverhead"):WaitForChild("TextLabel").Text = filteredText
		end
	end
end)

It’s not the character that has the issues. Maybe try printing out something when the nametag text changes (in-game).