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
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
it’s literally player.DisplayName
.
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
It’s a welcome message.
There is a remote event in ReplicatedStorage
called PlayerJoined.
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local remoteEvent = ReplicatedStorage:WaitForChild('PlayerJoined')
local function onPlayerJoin(player)
remoteEvent:FireAllClients(player.DisplayName)
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
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!