How would I get all players in a server besides the localplayer in a for loop?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Getting all players besides the localplayer (my self) in a for loop.
  2. What is the issue? Include screenshots / videos if possible!
    I’m not sure how to do it.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried looking thru some other posts and none include for loops.

You’d do something like this

local players = game:GetService("Player")

for _, player in pairs(players:GetPlayers()) do
    if player ~=  players.LocalPlayer then -- ~= means not equal so its checks if the player isnt the local player
        -- do whatever
    end
end
2 Likes