New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

How To Detect If A Player Does NOT Exist?

Asked by 10 days ago
Edited 9 days 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? b_mni 113 — 10d
1
btw can you paste the WHOLE code so I might be able to handle it better b_mni 113 — 10d
1
PRAW is what i use to invoke the players side of the chat EnzoTDZ_YT 314 — 10d

2 answers

Log in to vote
1
Answered by 9 days ago
Edited 9 days 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 314 — 9d
1
can you hide most of my code for privacy reasons? EnzoTDZ_YT 314 — 9d
1
sure HappyJakeyBoy 99 — 9d
1
done HappyJakeyBoy 99 — 9d
1
thanks jake EnzoTDZ_YT 314 — 9d
Ad
Log in to vote
-1
Answered by
b_mni 113
10 days 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 314 — 10d
1
more help? EnzoTDZ_YT 314 — 9d

Answer this question