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

How To Detect If A Player Does NOT Exist?

I have

elseif m == "/cmds" then
		PRAW(p,"_/[Administrator Commands]\_")
		PRAW(p,"/kick [PLAYERNAME]")
	elseif m:sub(1,6):lower() == "/kick " then
		if p.UserId == 261477936 then
			if m:lower() == "/kick" then
				PRAW(p,"Usage /kick [PLAYERNAME]")
			elseif m:lower() == "/kick" then
				PRAW(p,"Usage /kick [PLAYERNAME]")
			elseif m:sub(7) == "" then
				PRAW(p,"Usage /kick [PLAYERNAME]")
			else
				local PlayerToBeKicked = m:sub(7)
				for i, l in pairs(game.Players:GetPlayers()) do
					if m:sub(7) == not l.Name then
						print("Player Dosen't Exist.")
						PRAW(p,"Player "..m:sub(7).." Does Not Exist.")
					elseif l.Name == m:sub(7) then
						print("Player Exists.")
						game.Players:WaitForChild(PlayerToBeKicked):Kick("An Administrator Has Kicked You.")
					end	
				end
			end
		end

as a kick code in my custom chat i can kick the player but it dosent respond with player doesnt exist or appear in the messages.

ENTIRE CODE DELETED FOR PRIVACY

3 comments

1

what does PRAW mean?

1

btw can you paste the WHOLE code so I might be able to handle it better

1

PRAW is what i use to invoke the players side of the chat

2 answers

✓ Accepted answer

Try using FindFirstChild() it detects if it exists Source

	elseif m:sub(1,6):lower() == "/kick " then
		if p.UserId == 261477936 then
			if m:lower() == "/kick" then
				PRAW(p,"Usage /kick [PLAYERNAME]")
			elseif m:lower() == "/kick" then
				PRAW(p,"Usage /kick [PLAYERNAME]")
			elseif m:sub(7) == "" then
				PRAW(p,"Usage /kick [PLAYERNAME]")
			else
				local PlayerToBeKicked = m:sub(7)
				local PlayerPTK = game.Players:FindFirstChild(PlayerToBeKicked)
				for i, l in pairs(game.Players:GetPlayers()) do
					if PlayerPTK then
						print("Player Exists.")
						game.Players:WaitForChild(PlayerToBeKicked):Kick("An Administrator Has Kicked You.")
					elseif PlayerPTK == nil then
						print("The Player "..m:sub(7).." Was Not Found!")
						PRAW(p, "The Player "..m:sub(7).." Was Not Found!")
					end	
				end
			end
		end

5 comments

1

Thx jake

1

can you hide most of my code for privacy reasons?

0

sure

0

done

1

thanks jake

Maybe paste this into line 15 on That (--^) piece of code:

if l == nil then
print("No player found in server named "..m:sub(7))
PRAW(p, "Player does not exist in server. Name: "..m:sub(7))
end

2 comments

1

didnt work

1

more help?

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