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 4 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.

function OnPlayerEntered(player)
    if player.userId == game.CreatorId then --for the game owner, might remove it
        local msg = Instance.new("Message")
        msg.Parent = game.Workspace
        msg.Text = "The creator has joined the server!"
        wait(2)
        msg:remove()
    elseif player.Name == "Aprilsaurus" then --what I'm trying to work on
        local msg = Instance.new("Message")
        msg.Parent = game.Workspace
        msg.Text = "The Dev has joined this server!" --the text
        wait(10)
        msg:remove()
    end
end

game.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 — 4y
0
hold on it suddenly started working just now and i didn't even do anything Aprilsaurus 48 — 4y
0
Okay that worked, thank you! Aprilsaurus 48 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

You should be using .PlayerAdded instead of .ChildAdded

Try this:

local Players = game:GetService("Players")

local function playerAdded(Player)
    -- Rest of code here.
end
Players.PlayerAdded:Connect(playerAdded)
Ad

Answer this question