Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

2 comments

0

Hey Sorry but where to put this ?

0

I forgot to mention that, Oops! Put it in serverscriptservice (make sure its a serverscript)

This discussion is preserved as it was. New answers, comments, and votes are closed.