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
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.