Simple question on a simple script

This is a part of my script and I want it to not take the Username but the DisplayName.
How can I do that?

local function onPlayerJoin(player)
	remoteEvent:FireAllClients(player.Name)
end

The script is in ServerScriptService

1 Like

it’s literally player.DisplayName.

1 Like

https://developer.roblox.com/en-us/api-reference/property/Player/DisplayName

local function onPlayerJoin(player)
	remoteEvent:FireAllClients(player.DisplayName)
end

What is the script for? I’m just curious because you are firing all clients, and getting the player’s display name.

Oops. i was confused by the message in the output with another message that came from another script. now i have changed both :slight_smile:

It’s a welcome message.

There is a remote event in ReplicatedStorage called PlayerJoined.

This script in ServerScriptService
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local remoteEvent = ReplicatedStorage:WaitForChild('PlayerJoined')

local function onPlayerJoin(player)
	remoteEvent:FireAllClients(player.DisplayName)
end

game.Players.PlayerAdded:Connect(onPlayerJoin)
And this LocalScript in StarterPlayer < StarterPlayerScripts
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local remoteEvent = ReplicatedStorage:WaitForChild('PlayerJoined')

textColor = BrickColor.new('Cool yellow')

local function welcome(playerName)
	game.StarterGui:SetCore('ChatMakeSystemMessage', {
		Text = playerName..' has joined';
		Color = textColor.Color;
	})
end
remoteEvent.OnClientEvent:Connect(welcome)

Ohh! That’s nice, I wish you good luck on whatever your game is!