Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to announce when a certain player joined the game?

Asked by 5 years ago

I'm trying to find a script where is a certain user was to join the server, there will be a pop up on the screen saying "User joined the game!"

For some reason, the script isn't working though.

I found the script on an outdated youtube video and I'm trying to get it to work, here's what I have.

01function OnPlayerEntered(player)
02    if player.userId == game.CreatorId then --for the game owner, might remove it
03        local msg = Instance.new("Message")
04        msg.Parent = game.Workspace
05        msg.Text = "The creator has joined the server!"
06        wait(2)
07        msg:remove()
08    elseif player.Name == "Aprilsaurus" then --what I'm trying to work on
09        local msg = Instance.new("Message")
10        msg.Parent = game.Workspace
11        msg.Text = "The Dev has joined this server!" --the text
12        wait(10)
13        msg:remove()
14    end
15end
16 
17game.Players.ChildAdded:connect(OnPlayerEntered)

I don't see any errors in the output so I'm not sure why it's not working, any help is appreciated.

1
Try to use "PlayerAdded" and not "ChildAdded"; Players.PlayerAdded:Connect(OnPlayerEntered) NiniBlackJackQc 1562 — 5y
0
hold on it suddenly started working just now and i didn't even do anything Aprilsaurus 48 — 5y
0
Okay that worked, thank you! Aprilsaurus 48 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

You should be using .PlayerAdded instead of .ChildAdded

Try this:

1local Players = game:GetService("Players")
2 
3local function playerAdded(Player)
4    -- Rest of code here.
5end
6Players.PlayerAdded:Connect(playerAdded)
Ad

Answer this question