How to change a character's name?

I’ve been looking and trying to find a way how to do this. Everything I seem to do requires me to have permission level 4 or ROBLOX reverts the change after I rename it. (This is for admin commands so I don’t want to make a ui for the names.)

My Code:

_G.Name = function(char2, name, plr)
	if plr == nil then
		if game.Players:FindFirstChild(name.Name) then
			local Character = name.Character
			local Humanoid = Character.Humanoid

			name.DisplayName = char2
		end

		return
	end
	
	
	
	if char2 == "all" then
		for i,v in pairs(game.Players:GetChildren()) do
			local Character = v.Character
			local Humanoid = Character.Humanoid

			pcall(function()
				v.DisplayName = name
			end)
		end

		return
	end
	if char2 == "others" then
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Name ~= plr.Name then
				local Character = v.Character
				local Humanoid = Character.Humanoid

				pcall(function()
					v.DisplayName = name
				end)
			end
		end

		return
	end
	if char2 == "me" then
		if game.Players:FindFirstChild(plr.Name) then
			local Character = plr.Character
			local Humanoid = Character.Humanoid

			pcall(function()
				plr.DisplayName = name
			end)
		end

		return
	end
	
	for i,v in pairs(game.Players:GetChildren()) do
		local vName = string.lower(v.Name)
		if vName:sub(1, #char2) == char2 then -- 1 is where is starts, #char2 is how far to serch. 
			local Name = v.Name
			local Character = v.Character
			local Humanoid = Character.Humanoid
			
			pcall(function()
				v.DisplayName = name
			end)
			return
		end
	end
	
end

(The pcall function is there because of other scripts. It doesn’t mess it up btw.)
Any clues to my problem would help a-lot! Thanks. (Been at this for an hour .0. please help.)

1 Like

If you can’t figure it out, use billboard gui and make it look like a regular username with font, background transparency etc.

1 Like

I really would, but this is an admin command script. I don’t plan on making a billboard gui for every game that i’m going to put my admin in. Besides, I know khols admin made this possible, so there is no point on giving up. :slight_smile:

1 Like

I believe they do this by attaching a NPC head to the character’s head, making the character’s name invisible and giving the NPC the custom name. Have you tried doing that?

1 Like

Oh no. I haven’t even thought about that. Thank you!