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

How to access Player Gui??

Asked by 8 years ago

Here is my script its not a local script The problem is that it doesnt change the gui message. Its probly because i didnt access PlayerGui properly I want it to say the message if the ammount of players is below 2

local Teams = game.Teams
local Players = game.Players:GetPlayers()
local timeleft = game.Workspace.timeleft.Value

function Checkforplayers()

    if #Players >= 2 then

    else
        Players.PlayerGui.ScreenGui.Message.Text = "2 Players are needed! Invite a friend or come back later"
    end



end

function Createteams()
local Cops = Instance.new("Team")
Cops.Name = "Cops"
Cops.Parent = game.Teams
Cops.TeamColor = BrickColor.new("Bright blue")
wait(1)

end

while true do
    if #Players <= 1 then
        Checkforplayers()
        Createteams()
    end
end

Please help how do i do this?

1 answer

Log in to vote
0
Answered by 8 years ago

Players is merely a table of players. You need to iterate through it in order to set GUI text like that.

    for _, player in pairs(Players) do
        player.PlayerGui.ScreenGui.Message.Text = "2 Players are needed! Invite a friend or come back later"
    end

The rest of your script is pretty wacky, but I guess I answered your question.

1
Whatrs wacky about it? Bennymax3333 0 — 8y
Ad

Answer this question