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

How can I prevent a player from seeing a GUI after 2 players have joined?

Asked by 5 years ago
repeat

    if script.Parent.TextTransparency == 0 then
        wait()
    end

    if script.Parent.TextTransparency == 1 then


wait(10)
script.Parent.TextTransparency = 1
wait(0.1)
script.Parent.TextTransparency = 0.9
wait(0.1)
script.Parent.TextTransparency = 0.8
wait(0.1)
script.Parent.TextTransparency = 0.7
wait(0.1)
script.Parent.TextTransparency = 0.6
wait(0.1)
script.Parent.TextTransparency = 0.5
wait(0.1)
script.Parent.TextTransparency = 0.4
wait(0.1)
script.Parent.TextTransparency = 0.3
wait(0.1)
script.Parent.TextTransparency = 0.2
wait(0.1)
script.Parent.TextTransparency = 0.1
wait(0.1)
script.Parent.TextTransparency = 0

end until game.Players.NumPlayers >= 2

if script.Parent.TextTransparency == 1 then
    wait()
end

if script.Parent.TextTransparency == 0 then

script.Parent.TextTransparency = 0
wait(0.1)
script.Parent.TextTransparency = 0.1
wait(0.1)
script.Parent.TextTransparency = 0.2
wait(0.1)
script.Parent.TextTransparency = 0.3
wait(0.1)
script.Parent.TextTransparency = 0.4
wait(0.1)
script.Parent.TextTransparency = 0.5
wait(0.1)
script.Parent.TextTransparency = 0.6
wait(0.1)
script.Parent.TextTransparency = 0.7
wait(0.1)
script.Parent.TextTransparency = 0.8
wait(0.1)
script.Parent.TextTransparency = 0.9
wait(0.1)
script.Parent.TextTransparency = 1   

end      

i got this localscript, and it basically makes the text "waiting for players" appear for the first player that joins. when another player joins, the first player's text will fade out, and the second player SHOULDNT see the text at all. however, the 2nd player sees it fade in and out very quickly. how would i make the 2nd player not see the text at all?

1
My friend, have you heard of for loops Optikk 499 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

Explanation

To start, if the player can see the GUI fading out, this means that you will want to speed up the time it takes to fade out the GUI. Currently, the total fade out time is a whole 1 second that can be lowered.

The Solution

To start, you will want to learn how to use for loops. They can speed up the process of what you were doing. Instead of typing out every transparency change you can just use a for loop to automate it. You can read about for loops here.

In the script given, not only did I simplify the script lots, but did I make it fade faster. See if it works.

Here is the code:

repeat
    if script.Parent.TextTransparency == 0 then
        wait()
    end
    if script.Parent.TextTransparency == 1 then
        wait(10)
        for i = 1, 0, 0.1 do
            script.Parent.TextTransparency = i
            wait()
        end
        script.Parent.TextTransparency = 0 --For good measure
    end
until game.Players.NumPlayers >= 2

if script.Parent.TextTransparency == 1 then
    wait()
end

if script.Parent.TextTransparency == 0 then
    for i = 0, 1, 0.1 do
        script.Parent.TextTransparency = i
        wait()
    end
    script.Parent.TextTransparency = 1
end

If you have any other questions or comments, just reply to this answer! :)

-Crystal

0
NumPlayers is deprecated. Use #Players:GetPlayers() User#24403 69 — 5y
0
You really shouldn't try to make it as close to his as possible, even if you think he will be able to recognize it better, especially if it increases the complexity of the script. SteamG00B 1633 — 5y
Ad
Log in to vote
0
Answered by
SteamG00B 1633 Moderation Voter
5 years ago
Edited 5 years ago

The fact that there isn't a for or while loop there pains me. Crystal's solution is deprecated and a tad bit redundant, so here is probably the simplest solution to your problem.

while  #Players:GetPlayers() < 3 do
    if script.Parent.TextTransparency == 0
        for i=1,10 do
            script.Parent.TextTransparency = script.Parent.TextTransparency+0.1
            wait(0.01)
        end
    end
end

for i=1,10 do
    script.Parent.TextTransparency = script.Parent.TextTransparency-0.1
    wait(0.01)
end

What this should do is if the transparency of the text is 0 and there are no more than 2 players, it will fade in the text, and when there are at least 3 players in the game, it will fade the text out at the same rate as the fade in.

0
Look man no offence but I just simplified what he already had. I get that there are better ways but still. Crystalflxme 104 — 5y
0
Your answer was wrong though. SteamG00B 1633 — 5y

Answer this question