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

How To Detect If A Player Does NOT Exist?

Asked by 4 years ago
Edited 4 years ago

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

1
what does PRAW mean? User#29913 36 — 4y
1
btw can you paste the WHOLE code so I might be able to handle it better User#29913 36 — 4y
1
PRAW is what i use to invoke the players side of the chat EnzoTDZ_YT 275 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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
1
Thx jake EnzoTDZ_YT 275 — 4y
1
can you hide most of my code for privacy reasons? EnzoTDZ_YT 275 — 4y
0
sure HappyJakeyBoy 67 — 4y
0
done HappyJakeyBoy 67 — 4y
1
thanks jake EnzoTDZ_YT 275 — 4y
Ad
Log in to vote
-1
Answered by 4 years ago

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
1
didnt work EnzoTDZ_YT 275 — 4y
1
more help? EnzoTDZ_YT 275 — 4y

Answer this question