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

How Do I reference all players in workspace?

local player = game.Players.LocalPlayer -- gets local player name in game.players

local localplayer = player.Character --finds local player in workspace

this is what I tried but it doesn't seem to work

2 comments

0

That should work

0

Is FilteringEnabled on or off?

2 answers

###You can use a for loop to iterate through the players.

for _, player in pairs(game:GetService("Players"):GetPlayers()) do
    local character = player.Character -- getting each character
end

Hopefully this works for you.

local Player = game.Players.LocalPlayer
local Character = workspace:WaitForChild(Player.Name)

print(Character.Name)

2 comments

0

No, why would you get it from the workspace?

0

To add it to a model so when the model moves, it moves along with it

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