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

How to get all Players except local player??

Asked by 2 years ago

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

0
Put your code into a code block. Also can you explain what you're trying to achieve. MarkedTomato 810 — 2y

1 answer

Log in to vote
0
Answered by
SuperPuiu 497 Moderation Voter
2 years ago

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
0
Removing the local player from the existing :GetPlayers() one, would be more efficient than creating a new table. Aimarekin 345 — 2y
Ad

Answer this question