#Joining message

1 messages · Page 1 of 1 (latest)

slim spindle
#

I tried something but I don't know why isn't it working and I don't know how to fix it

#

I am using a local script

#

what should I use ?

narrow gulch
slim spindle
narrow gulch
slim spindle
# narrow gulch show the code
local Players = game:GetService("Players")
local TextChatService = game:GetService("TextChatService")

local function PlayerAdded(player)
    local playerName = player.Name
    local message = playerName .. " has joined the game!"
    TextChatService:DisplaySystemMessage(message)
end

Players.LocalPlayer:Connect(PlayerAdded)```
narrow gulch
#

no localplayer isnt an event

slim spindle
#

a

narrow gulch
#

u can do
player = Players.LocalPlayer

#

to get the name of the player

#

u dont need any functions
the code in local script will run when player joins anyway

slim spindle
#

like this ?

narrow gulch
#

yes

#

and now just add the code u had in the function

slim spindle
#

and I replace the LocalPlayer by player ?

narrow gulch
narrow gulch
#

why would he do that

slim spindle
#

if I don't use the player thing why do i ad it then ?

narrow gulch
#

local scripts run when the player running the script is added u dont need any events

slim spindle
#

I am new to scripting so I wont be able to understand everything

narrow gulch
# slim spindle

local Players = game:GetService("Players")
local TextChatService = game:GetService("TextChatService")
local player = Players.LocalPlayer

local message = player.Name.." has joined the game!"
TextChatService:DesplaySystemMessage(message)

narrow gulch
slim spindle
#

I did this but its still not working

slim spindle
narrow gulch
#

u also dont need the function

slim spindle
#

huh

narrow gulch
# slim spindle I don't need ?

how local scripts work is that every player runs their own local script
and they start running when the player joins the game
u can use the Players.LocalPlayer to get the player that is running the script

slim spindle
#

why It's not working too

#

@narrow gulch

viscid acorn
#

add one inside textchatservice

#

you should see it on your explorer tab

#

use the plus button

#

and then reference it in the script

#
local TextChannel = game:GetService("TextChatService").TextChannel