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

How do I access every players proporties?

Asked by
NecoBoss 194
10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I need to access every players character and PlayerGui. How would I do this? This is the script I have been working on but it doesn't work:

local numPlayers = #game:GetService("Players"):GetPlayers();

if numPlayers < 2 then
    for i, v in pairs (game.Players:GetPlayers()) do
    v.PlayerGui.ScreenGui.Frame.TextLabel = "Not Enough"
    end
elseif numPlayers > 1 then
    for i, v in pairs (game.Players:GetPlayers()) do
        v.PlayerGui.ScreenGui.Frame.TextLabel = "Enough"
    end
end

0
Currently, your script only checks if there are enough players once, if you want the script to continually check use a loop. To access a Player's Gui, you have correct. To access a Player's Character just use v.Character and mess around with their humanoid or torso. M39a9am3R 3210 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

Why don't you just use LocalPlayer in a Local Script? That should be pretty simple.

while wait() do --This will create an infinite loop. If you're looking for rounds to occur, simply add in a wait tag inside and change while wait() to while true.
local numPlayers = #game.Players:GetChildren() --I prefer GetChildren, though feel free to use GetPlayers if you have added anything to the Players
local Player = game.Players.LocalPlayer

--One of your problems was that you had the Hierarchy wrong. Players' Guis go to the "PlayerGui" folder inside of the Player.
if numPlayers < 2 then
    Player.PlayerGui.ScreenGui.Frame.TextLabel.Text = "Not Enough" --You just had TextLabel, when you need to get the Text property of TextLabel.
elseif numPlayers > 1 then --Also, you ended the if statement before the elseif, which is wrong.
    Player.PlayerGui.ScreenGui.Frame.TextLabel.Text = "Enough"
else
print("An error has occurred with the TextLabel script.")
return
end --End if statement below elseif statement
end --End loop

I hope this works, if not then let me know what your output is looking like.

Ad

Answer this question