How to make this Roleplay name serverside

I am using this script for my cloned player morphs roleplay name. This script creates a new folder inside a player’s cloned morph model with a humanoid that has a different name. But the problem is the roleplay name is only visible to me but not to other players. I want the rp name visible to everyone in the game.

image

`local chat = game:GetService("Chat")

script.Parent.FocusLost:connect(function(enter)
    if enter then
        local v = game.Players.LocalPlayer
        for a, mod in pairs(v.Character:children()) do
            if mod:findFirstChild("NameTag") then
                v.Character.Head.Transparency = 0.99 mod:Destroy()
            end
        end

        local char = v.Character
        local mod = Instance.new("Model", char)
        mod.Name = chat:FilterStringForBroadcast(script.Parent.Text, v)
        local cl = char.Head:Clone()
        cl.Parent = mod

        local hum = Instance.new("Humanoid", mod)
        hum.Name = "NameTag"
        hum.MaxHealth = 0
        hum.Health = 0

        local weld = Instance.new("Weld", cl) weld.Part0 = cl weld.Part1 = char.Head

        char.Head.Transparency = 1
        char.Head.face: Destroy ()
    end
end)`

Why don’t you just change the name of the player’s display name instead of adding another humanoid?

Server-Sided


RemoteEvent.OnServerEvent:Connect(function(plr, NewName)
    plr.Character.Humanoid.Display.Name = NewName
end)

Imma try it and let you know cause I did try something similar which was causing issues cause players were using the same cloned morph and the rp name was getting changed to the current player’s name I don’t know why. but this one looks promising.

The way you would want to do this is with a billboardgui and a remote event. Can’t give you an example because I’m on mobile, but here are some relevant links.

Remote Events

Billboard Guis

Fixed Display Name


This isn’t changeable because this is the players official display name.
plr.DisplayName

Edit Display Name


This is changeable and is the one I’m talking about.

plr.Character.Humanoid.DisplayName

My display name changed to “Type” whenever I am firing the name.
I think it is not delivering the name properly.
Here is my codes:
Local:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RPname")
local name = script.Parent.Text
script.Parent.FocusLost:connect(function(enter)
    if enter then
      remoteEvent:FireServer(name)
    end
end)

ServerScriptServiece:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RPname")


remoteEvent.OnServerEvent:Connect(function(plr, name)
	plr.Character.Humanoid.DisplayName = name
end)	

Debug the “name” variable for both server and client side (add print(name))

1 Like

image

It is a giving type.
looks like I forgot to tell the script that it should change the text to what I am writing in it before firing it.

I think I know whats your problem:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RPname")

script.Parent.FocusLost:connect(function(enter)
    if enter then
      local name = script.Parent.Text --Moved this inside here because it doesn't see it changing outside
      remoteEvent:FireServer(name)
    end
end)

This is a common mistake I see people do with values or text.

They try using .Value or .Text in a variable meaning it’s stuck on what it was when you made that variable. So you must always make variables of the object and use .Text or .Value when you need them so it gives you the latest value.

1 Like

Ok so thanks to you now the display name is changed. I will check if it is changed in serverside.

Thank you so much, it is working parfectly.

No problem, hope your game looks good with this system!

1 Like

Make sure to also filter the name before applying it on the server since people can set their names to something inappropriate.

1 Like