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

Help With Gui Countdown?

Asked by
Scootakip 299 Moderation Voter
9 years ago
01for i, player in ipairs(game.Players:GetChildren()) do
02SGGUI = Instance.new("ScreenGui")
03SGGUI.Parent = script.Parent:findFirstChild("tpscript") --Change this to the name of your script
04SGGUIT = Instance.new("TextBox")
05SGGUIT.Parent = SGGUI
06SGGUIT.Size = UDim2.new(.25, 0, .1, 0) --Change this to whatever you want the size to be
07SGGUIT.Font = "SourceSansBold" --Change this to whatever you want the font to be
08SGGUIT.FontSize = "Size18" --Change this to whatever you want the font size to be
09SGGUIT.BackgroundColor3 = Color3.new(.128, .128, .128) --Change this to whatever you want the background color to be
10SGGUIT.TextColor3 = Color3.new(1,1,1)
11SGGUI.Parent = player.PlayerGui
12 
13beep.Pitch = .5
14 
15SGGUIT.Text = "Game Starting in 5"
View all 32 lines...

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.

2 answers

Log in to vote
0
Answered by 9 years ago

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:

1local inst = script.Parent --The text or whatever
2wait()
3for a=5,0, -1 do
4 
5    inst.Text =  "Game Starting In  "..a..""
6    wait(1)
7end
8script.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]

1for _, player in pairs(game.Players:GetChildren()) do
2    Gui = {game.Lighting.TimerGui:Clone()}
3    wait()  
4    Gui[1].Parent = player.PlayerGui
5end
6wait(3)
7script:Remove() --Removes leftover script/Feel free to remove this.

Hope I somehow helped... ;p

0
Why use the table? You can just set Gui to game.Lighting.TimerGui:clone() Tkdriverx 514 — 9y
0
If you had multiple guis CarterTheHippo 120 — 9y
Ad
Log in to vote
0
Answered by
Tkdriverx 514 Moderation Voter
9 years ago

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"

01local timeValue = game.ReplicatedStorage:WaitForChild("Timer")
02local timerActive = false
03 
04-- YOUR CODE HERE (MOST LIKELY RANDOM FUNCTIONS, ETC.) --
05 
06while 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 
View all 27 lines...

"LocalGui"

01local gui = script.Parent
02local label = gui:WaitForChild("Background"):WaitForChild("TimerLabel")
03local timeValue = game.ReplicatedStorage:WaitForChild("Timer")
04 
05function 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)
View all 30 lines...

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.

Answer this question