Hey! I've been wondering how to get the players in my game but make it ignore myself. I'm pretty sure this is a simple couple line script. I've tried GetPlayers(), game.Players:GetChildren(), etc... Nothing really works. I've also tried the "for i,v in pairs()) do" thing.
✓ ANSWER ACCEPTED
How would I get the other players in the game?
1 answer
✓ Accepted answer
Hey quack,
What you are trying to do is impossible! Just kidding. Anyways, you just need to make a LocalScript(client-side of course) and loop through all the players and put an if statement in the loop to check if the player that it's currently looping through has the same name as the LocalPlayer's. If it doesn't, then you can go ahead and execute the rest of the code. Easier shown than just explaining so, check the code below and I'll explain line by line, unless it's obvious.
####Script Example
local plrs = game:GetService("Players"); -- Players Service.
local plr = plrs.LocalPlayer;
function check_plrs()
for _, plr2 in next, plrs:GetPlayers() do -- For each iteration, :GetPlayers() returns a table with all of the players inside of it.
if plr2.Name ~= plr.Name then -- Checks if the current player it's looping through is the LocalPlayer or not.
print("It's not me; it'", plr2.Name..".");
end
end
end
##Well, I hope I helped and have a nice day/night.
###Thanks,
###~~ KingLoneCat
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
if v ~= player then
oh, I feel stupid then lol.
Idk why I just constructed that whole answer.
local players = game.Players.LocalPlayer ?