How do I made a nameTag script like Admin systems?

So when you use Admin systems like Adonis or HD admin. They always this feature which allows the Moderator player to make a nametag to anyone they like by chatting in chat with *:name (player name) (anything they want).

I’m trying to figure out, how to do this (with the same font etc) with a GUI button which when clicked changes the person who click the GUI to a nametag named Red Team. If possible, I would like this to be changeable back into anything by the moderator (group rank ID) just the chat.

Hope someone will help as I’m very clueless.

Here is how the nametag is changed by Adonis Admin. https://gyazo.com/a6cdecef5effec047c72e264a8a3111f

Thanks , bartekx2007x.

2 Likes

Change Character.Humanoid.DisplayName to whatever you want to achieve this. You will not be able to see your own name as this is completely normal for roblox as you can see at the start of your GIF you were not able to see your own name:
image

To achieve seeing your own name you should make a Model with a Part called “Head” and a Humanoid iside of it. You would name the model to whatever you want the nickname to be or change the .DisplayName property of the Humanoid as shown above.

2 Likes
local function getPlayer(name)
    for i, v in pairs(game.Players:GetChildren()) do
        if string.lower(name) == string.lower(string.sub(v.Name, 1, #name)) then
            return v
            break
        end
    end
end
game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        player.Chatted:Connect(function(msg)
            if msg:sub(1, 6) == ':name ' then
                local plr = string.sub(msg:sub(7))[1]
                local newName = string.sub(msg:sub(7))[2]
                if getPlayer(plr) then
                    getPlayer(plr).Character.Humanoid.DisplayName = game:GetService('TextService'):FilterStringAsync(newName)
                end
            end
        end)
    end)
end)
2 Likes

The code you would need to use to name the player.

local function name(character, nickname)
	if workspace:FindFirstChild(character.Name .. "'s nickname") then -- if there is already a nickname for the player
		local model = workspace[character.Name .. "'s nickname"] -- get the model
		model.Humanoid.DisplayName = nickname -- change the name
	else
		local model = Instance.new("Model")
		model.Name = character.Name .. "'s nickname" -- Important so we can retreive it later
		
		
		local head = Instance.new("Part")
		head.Name = "Head" -- Has to be called Head else it won't work
		
		head.CanCollide = false -- So you can't touch it
		head.Size = Vector3.new()*1.5 -- So the head is about the side of a roblox head, we can't make it the exact size because of hitboxes.
		head.Transparency = 1 -- This is so you can't see it
		
		local humanoid = Instance.new("Humanoid")
		humanoid.DisplayName = nickname
		humanoid.BreakJointsOnDeath = false -- so the weld does not get destroyed
		humanoid.RequiresNeck = false
		humanoid.MaxHealth = 0
		humanoid.Health = 0 -- Just to be sure this is set to 0 as well
		
		local weld = Instance.new("ManualWeld") -- So the name sticks with the player
		weld.Part0 = head
		weld.Part1 = character.Head
		 
		-- Parent it all together to make it visible
		weld.Parent = weld.Part0
		head.Parent = model
		humanoid.Parent = model
		model.Parent = workspace 
	end	
end

You can use the code above with @GoteeSign’s code to create this effect:
image

2 Likes

Ok let say I had a simple GUI Button on starter GUI. And when I click it, it changes my name to Red Team.

What do I do?

You’d basically call the function that KJry_s stated everytime when the player clicks the button in a default script.


local Players = game:GetService('Players')

local button = script.Parent
local player = button:FindFirstAncestorWhichIsA('Player')

local newName = 'Red Team'

local function name(character)
	if workspace:FindFirstChild(character.Name .. "'s nickname") then -- if there is already a nickname for the player
		local model = workspace[character.Name .. "'s nickname"] -- get the model
		model.Humanoid.DisplayName = newName -- change the name
	else
		local model = Instance.new("Model")
		model.Name = character.Name .. "'s nickname" -- Important so we can retreive it later
		
		
		local head = Instance.new("Part")
		head.Name = "Head" -- Has to be called Head else it won't work
		
		head.CanCollide = false -- So you can't touch it
		head.Size = Vector3.new()*1.5 -- So the head is about the side of a roblox head, we can't make it the exact size because of hitboxes.
		head.Transparency = 1 -- This is so you can't see it
		
		local humanoid = Instance.new("Humanoid")
		humanoid.DisplayName = newName
		humanoid.BreakJointsOnDeath = false -- so the weld does not get destroyed
		humanoid.RequiresNeck = false
		humanoid.MaxHealth = 0
		humanoid.Health = 0 -- Just to be sure this is set to 0 as well
		
		local weld = Instance.new("ManualWeld") -- So the name sticks with the player
		weld.Part0 = head
		weld.Part1 = character.Head
		 
		-- Parent it all together to make it visible
		weld.Parent = weld.Part0
		head.Parent = model
		humanoid.Parent = model
		model.Parent = workspace 
	end	
end

button.MouseButton1Click:Connect(function()
name(player.Character)
end)
1 Like

https://gyazo.com/8b3704ee15524312468d351df30b29b2

nothing.

I put a print function after the name(player.Character) on the last line before end) to see if it was my fault localising the button, which looks like it working but the function it self isn’t.

It does make a model in workspace with players name and nickname but isn’t exa

I looked into script output and no error is showing up.

But It does make a model with all things inside - https://gyazo.com/73d9e22d21e6996cc595a4cb9209f006

The changes are only being made to the client, that’s the thing

Here’s what I think you can do:

  • Create a RemoteEvent inside ReplicatedStorage
  • Set this as your LocalScript for detecting the button when activated:
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local Button = script.Parent
local NameChange = "Red Team"

local function Clicked()
    print("Clicked")
    Event:FireServer(NameChange)
end

Button.MouseButton1Down:Connect(Clicked)
  • Handle the name changes on the server instead of on the client:
--Server Script inside ServerScriptService
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")

Event.OnServerEvent:Connect(function(Player, NameChange)
    print("Event fired")
    print("Name: ", NameChange)

    local Char = Player.Character
    if Char then
        Char.Humanoid.DisplayName = NameChange
    end
end)

I believe this can work, but I’m not exactly sure

1 Like

Ok let me get this straight.

RemoteEvent ------- Replicated Storage
LocalScript ------ Inside the RemoteEvent
Put the first code of line to that Local script.
Make the Serverscript that inside the ServerScriptService with that code you put in.

Where should the code that @flkfv said.

You should put the code that I stated inside the button and as a normal script (so everyone can see it).

1 Like

I’m not sure if it works or not. I’d recommend using @JackscarIitt’s method instead.

1 Like

Ok let me try now. I’ll see if it works.

I mean you can either do it that way or @flkfv’s way, although I do remember some issues with keeping regular ServerScripts inside descendants of GUI Objects

1 Like

Ok this is what I got.Screenshot 2021-04-15 at 18.58.34

nothing.

https://gyazo.com/a8fe3b03358f60aafd732fdfaa89b7de

it just makes models of stuff in Workspace.
Screenshot 2021-04-15 at 19.06.22

No errors.

Um did you mix up the 2

Your LocalScript should belong inside the Button, and the script that detects the Event should go in ServerScriptService

1 Like

As other’s have said, you use Character.Humanoid.DisplayName

I do not believe in spoonfeeding however so here’s a good resource to look at:

1 Like

Alright so first, delete the script inside the textbutton, next put the localscript inside the button, and then it should be fixed.

1 Like

Ok let me redo this.

Screenshot 2021-04-15 at 20.09.53
This is what I have at the moment.

In the first server script, I got :

local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")


local button = script.Parent
local player = button:FindFirstAncestorWhichIsA('Player')

Event.OnServerEvent:Connect(function(Player, NameChange)
	print("Event fired")
	print("Name: ", NameChange)

    local Char = Player.Character
        if Char then
		Char.Humanoid.DisplayName = NameChange
	end
end)

In the second local script, I got :

local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")

local Button = script.Parent

local NameChange = "Red Team"

local function Clicked()

print("Clicked")

Event:FireServer(NameChange)

end

Button.MouseButton1Down:Connect(Clicked)

In the third local script I got :

local Players = game:GetService('Players')

local button = script.Parent
local player = button:FindFirstAncestorWhichIsA('Player')

local newName = 'Red Team'

local function name(character)
	if workspace:FindFirstChild(character.Name .. "'s nickname") then -- if there is already a nickname for the player
		local model = workspace[character.Name .. "'s nickname"] -- get the model
		model.Humanoid.DisplayName = newName -- change the name
	else
		local model = Instance.new("Model")
		model.Name = character.Name .. "'s nickname" -- Important so we can retreive it later


		local head = Instance.new("Part")
		head.Name = "Head" -- Has to be called Head else it won't work

		head.CanCollide = false -- So you can't touch it
		head.Size = Vector3.new()*1.5 -- So the head is about the side of a roblox head, we can't make it the exact size because of hitboxes.
		head.Transparency = 1 -- This is so you can't see it

		local humanoid = Instance.new("Humanoid")
		humanoid.DisplayName = newName
		humanoid.BreakJointsOnDeath = false -- so the weld does not get destroyed
		humanoid.RequiresNeck = false
		humanoid.MaxHealth = 0
		humanoid.Health = 0 -- Just to be sure this is set to 0 as well

		local weld = Instance.new("ManualWeld") -- So the name sticks with the player
		weld.Part0 = head
		weld.Part1 = character.Head

		-- Parent it all together to make it visible
		weld.Parent = weld.Part0
		head.Parent = model
		humanoid.Parent = model
		model.Parent = workspace 
	end	
end

button.MouseButton1Click:Connect(function()
	name(player.Character)
end)

Hope this is now clear.

Nothing has worked and no error in output script.

If you can dm me at Royal#1879, I can fix this up for you honestly