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

How Do I reference all players in workspace?

Asked by 6 years ago

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

0
That should work greatneil80 2647 — 6y
0
Is FilteringEnabled on or off? Jexpler 63 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago

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
Ad
Log in to vote
0
Answered by 6 years ago

Hopefully this works for you.

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

print(Character.Name)
0
No, why would you get it from the workspace? User#19524 175 — 6y
0
To add it to a model so when the model moves, it moves along with it FirezoneGamez 155 — 6y

Answer this question