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

Help w/ playergui visible?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

I need help with getting players and making their gui visible for 2 seconds.

    players = game.Players:GetChildren()
        for i,v in pairs (players) do
            players.PlayerGui.TimeNote.Timer2.Visible = true
            wait(2)
            players.PlayerGui.TimeNote.Timer2.Visible = false

        end

2 answers

Log in to vote
1
Answered by
Azmidium 388 Moderation Voter
8 years ago

Your issue is that you're accessing the player wrong, the script below accesses the player in the correct way.

players = game.Players:GetChildren()
for i,v in pairs (players) do
    -- When doing loops you use the second variable you create as the "child"
    v.PlayerGui.TimeNote.Timer2.Visible = true
    wait(2)
    v.PlayerGui.TimeNote.Timer2.Visible = false
end

Hope this helped!

Sincerely, jmanrock123

0
This still won't work as intended. The function for each player needs to be asynchronous, else it won't work properly. Programmix 285 — 8y
Ad
Log in to vote
1
Answered by 8 years ago

Here's a fixed version of your script:

for _, player in pairs(game.Players:GetChildren()) do
    spawn(function()
        player.PlayerGui.TimeNote.Timer2.Visible = true
        wait(2)
        player.PlayerGui.TimeNote.Timer2.Visible = false
    end)
end

What you were doing wrong is referencing the player incorrectly. You also should use spawn to spawn the function, else this will happen for one player after the next and not at the same time.

What spawn does is run a function, but still continue with the rest of the code without stopping if there's a pause (like using wait).

I hope this helps! Good luck.

Answer this question