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

How to get all Players except local player??

I would like this script to target every player in the game except for the local player, idk lua so any help would be very muchly appreciated.

while true do wait(0) local args = { [1] = { [1] = game:GetService("Players").meh_anxiety.Character.HumanoidRootPart } } game:GetService("ReplicatedStorage").Events.SwingTool:FireServer(unpack(args)) end

1 comment

0

Put your code into a code block. Also can you explain what you're trying to achieve.

1 answer

In a local script:

local Player = game.Players.LocalPlayer
local playersTable = {} -- Used to store players

for i,v in pairs(game.Players:GetPlayers() do
      if v ~= Player then
     table.insert(playersTable, v)
      end
end

To use the table, you will have to use a for loop:

for i,plr in pairs(playersTable) do
       -- do something
end

1 comment

0

Removing the local player from the existing :GetPlayers() one, would be more efficient than creating a new table.

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