How do I get all players from a remote event and anchor them besides the person who fired the remote event?

How do I get all players from a remote event and anchor them besides the person who fired the remote event?
Script:
local player = game.Players.LocalPlayer
game:GetService(“ReplicatedStorage”).TimeStop.OnServerEvent:connect(function(plr)
game.Workspace.TSSound:Play()
wait(3.2)
local Wave1 = Instance.new(“Part”)
Wave1.Name = “TimeWave1”
Wave1.Parent = game.Workspace
Wave1.Shape = Enum.PartType.Ball
Wave1.Anchored = true
Wave1.CanCollide = false
Wave1.Material = Enum.Material.ForceField
Wave1.Transparency = 0.4
Wave1.BrickColor = BrickColor.new(“Lime green”)
Wave1.Size = Vector3.new(0.7, 0.7, 0.7)
local Wave2 = Instance.new(“Part”)
Wave2.Name = “TimeWave2”
Wave2.Parent = game.Workspace
Wave2.Shape = Enum.PartType.Ball
Wave2.Anchored = true
Wave2.CanCollide = false
Wave2.Material = Enum.Material.ForceField
Wave2.Transparency = 0.4
Wave2.BrickColor = BrickColor.new(“New Yeller”)
Wave2.Size = Vector3.new(0.9, 0.9, 0.9)
local Wave3 = Instance.new(“Part”)
Wave3.Name = “TimeWave3”
Wave3.Parent = game.Workspace
Wave3.Shape = Enum.PartType.Ball
Wave3.Anchored = true
Wave3.CanCollide = false
Wave3.Material = Enum.Material.ForceField
Wave3.Transparency = 0.4
Wave3.BrickColor = BrickColor.new(“Magenta”)
Wave3.Size = Vector3.new(1.1, 1.1, 1.1)
Wave1.CFrame = plr.Character.HumanoidRootPart.CFrame
Wave2.CFrame = plr.Character.HumanoidRootPart.CFrame
Wave3.CFrame = plr.Character.HumanoidRootPart.CFrame
local tweenService = game:GetService(“TweenService”)
local tweenInformation = TweenInfo.new(
.5,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut,
0,
true,
0
)

local partInfo1 = {

Size = Wave1.Size * Vector3.new(250, 250, 250)

}

local partInfo2 = {

Size = Wave2.Size * Vector3.new(250, 250, 250)
}

local partInfo3 = {

Size = Wave3.Size * Vector3.new(250, 250, 250)
}

local tween1 = tweenService:Create(Wave1, tweenInformation, partInfo1)
local tween2 = tweenService:Create(Wave2, tweenInformation, partInfo2)
local tween3 = tweenService:Create(Wave3, tweenInformation, partInfo3)

tween1:Play()
teen2:Play()
tween3:Play()
wait(1)
Wave1:Destroy()
Wave2:Destroy()
Wave3:Destroy()
workspace.Music.Song:Stop()
workspace.TSColorCorrection.Parent = game.Lighting
– How do I anchor every player’s character’s body parts except the person who fired the remote event
– BTW all this code runs when a client presses the key F then it fires a remote event through the server
wait(9)
workspace.Music.Song:Resume()
game.Lighting.TSColorCorrection.Parent = game.Workspace
workspace.TSResume:Play()
– Right here is where the character’s body parts would unanchor
end)

1 Like

To get all players other than your own:

for _, otherPlayer in next, game.Players:GetPlayers() do
    if otherPlayer ~= player then
        -- Anchor body parts of otherPlayer.Character
    end
end

Ive done it. Thank you so much.

Nitpick but please use ipairs when iterating through arrays, not in next. In the first place you should aim to use the two proper functions for iteration, pairs or ipairs. next is no longer the fastest method of iteration, idiomatically it’s improper (though pairs call(s/ed) next) and ipairs makes it more clear what you’re iterating over.

3 Likes

Didn’t know that actually, thanks for the heads up.

1 Like

Not only this, but ipairs is also considerably faster in Luau, unlike in vanilla Lua.

2 Likes

Should I be concerned about ipairs? I have no idea what that means.

https://www.lua.org/pil/7.3.html

1 Like