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

How to check if someone joins and match's one of the names?

Asked by 3 years ago

I To make it run the code after "Then" If the player that joined match's one of the names it runs the code for the name.

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    if player.Name == "Hamoodiyt" then
        print("the CEO joined") 
    elseif player.Name == "Agenerousguy" then
        print("the Builder joined") 
    elseif player.Name == "YOBECOOLL!" then
        print("the Co-CEO joined")  
    end
end)

To be clear. I am not a pro at this, I started Learning Lua about 2 weeks ago

1 answer

Log in to vote
0
Answered by 3 years ago

Just create a variable and compare the variable to the player's name.

local ceo = "CEOName"
local builder = "BuilderName"

game.Players.PlayerAdded:Connect(function(player)
    if ceo == player.Name then
        print("ceo joined")
    elseif builder == player.Name then
        print("builder joined")
    end
end)
0
Hey Sorry but where to put this ? Hamoodiyt 26 — 3y
0
I forgot to mention that, Oops! Put it in serverscriptservice (make sure its a serverscript) kegirosou 17 — 3y
Ad

Answer this question