01 | for i, player in ipairs (game.Players:GetChildren()) do |
02 | SGGUI = Instance.new( "ScreenGui" ) |
03 | SGGUI.Parent = script.Parent:findFirstChild( "tpscript" ) --Change this to the name of your script |
04 | SGGUIT = Instance.new( "TextBox" ) |
05 | SGGUIT.Parent = SGGUI |
06 | SGGUIT.Size = UDim 2. new(. 25 , 0 , . 1 , 0 ) --Change this to whatever you want the size to be |
07 | SGGUIT.Font = "SourceSansBold" --Change this to whatever you want the font to be |
08 | SGGUIT.FontSize = "Size18" --Change this to whatever you want the font size to be |
09 | SGGUIT.BackgroundColor 3 = Color 3. new(. 128 , . 128 , . 128 ) --Change this to whatever you want the background color to be |
10 | SGGUIT.TextColor 3 = Color 3. new( 1 , 1 , 1 ) |
11 | SGGUI.Parent = player.PlayerGui |
12 |
13 | beep.Pitch = . 5 |
14 |
15 | SGGUIT.Text = "Game Starting in 5" |
Basically, before the round starts a Gui pops up and has a number count down from 5 to 1. It works fine on its own, but when there is more than one player, not every player gets the gui at the same time, instead it gives each player the gui and countdown individually. Basically, once the gui counts down and destroys for player one, it will then go to player two, rather than doing both players at the same time. Can someone help me fix this issue, it'll be a big issue if there are a lot of players in the game.
I would reccoment putting a gui in the lighting set to correct proportions and such then Cloning it into player's PlayerGui.
Script that would go into the Gui:
1 | local inst = script.Parent --The text or whatever |
2 | wait() |
3 | for a = 5 , 0 , - 1 do |
4 |
5 | inst.Text = "Game Starting In " ..a.. "" |
6 | wait( 1 ) |
7 | end |
8 | script.Parent.Parent:Destroy() --The text thingies parent/ScreenGui |
You would just put that gui into lighting and then have this script clone it into the player's PlayerGui. [Which is easy :p]
1 | for _, player in pairs (game.Players:GetChildren()) do |
2 | Gui = { game.Lighting.TimerGui:Clone() } |
3 | wait() |
4 | Gui [ 1 ] .Parent = player.PlayerGui |
5 | end |
6 | wait( 3 ) |
7 | script:Remove() --Removes leftover script/Feel free to remove this. |
Hope I somehow helped... ;p
View the hierarchy here. The actual GUI size, color, etc. can be anything you like. Also, the name of the scripts don't matter, so they can be anything you want.
Make sure you have FilteringEnabled set to true (but it really doesn't have to).
"ServerScript"
01 | local timeValue = game.ReplicatedStorage:WaitForChild( "Timer" ) |
02 | local timerActive = false |
03 |
04 | -- YOUR CODE HERE (MOST LIKELY RANDOM FUNCTIONS, ETC.) -- |
05 |
06 | while true do -- Infinite loop |
07 | -- YOUR CODE HERE (PRE-TIMER) -- |
08 | timerActive = true |
09 | timeValue.Value = 60 -- The time it starts with. |
10 |
11 | while timerActive do |
12 | wait( 1 ) |
13 |
14 | timeValue.Value = timeValue.Value - 1 |
15 |
"LocalGui"
01 | local gui = script.Parent |
02 | local label = gui:WaitForChild( "Background" ):WaitForChild( "TimerLabel" ) |
03 | local timeValue = game.ReplicatedStorage:WaitForChild( "Timer" ) |
04 |
05 | function formatTime(input) |
06 | local output |
07 |
08 | if type (input) ~ = "number" or input < 0 then -- Makes sure it's a number, OR if it's a number and it's a negative number. |
09 | output = "--:--" |
10 | else |
11 | local formatString = "%i:%.2i" -- This is just a formatting string. |
12 | local seconds = math.floor(input % 60 ) -- input % (modulo) 60 gets the remainder of the division of input and 60. Ex: input = 65; 65 % 60 is 5 |
13 | local minutes = math.floor(input / 60 ) -- math.floor rounds numbers down towards negative infinity. Just in case input / 60 is a decimal, it becomes a whole number. |
14 |
15 | output = formatString:format(minutes, seconds) |
The -- YOUR CODE HERE --
is where your code should go.
I hope this helped. If you have any questions, feel free to contact me or just post a comment on this answer.