Hi, i've a Local Script that controls time display and gui animation when there is extra added time or the game ends. Anyway the time script is controlled by server script ( to display the same time for everyone ). The problem is that the local script isn't doing the while true do
part.
Local Script:
01 | local added = game.Workspace.Time.Added.Value |
02 | local waitsecs = game.Workspace.Time.Wait.Value |
03 | local min = game.Workspace.Time.Minutes.Value |
04 | local sec = game.Workspace.Time.Seconds.Value |
05 | local randomsec = game.Workspace.Time.Wait.Value |
06 |
07 | game.Workspace.Time.Changed:Connect( function () |
08 | script.Parent.Purple.Time.Text.Text = game.Workspace.Time.Value |
09 | end ) |
10 |
11 | while true do |
12 | wait(waitsecs) |
13 | print ( "Check" ) -- Checking if the main While loop is working |
14 | if min = = 45 and sec > = 10 then |
15 | print ( "Extra" ) -- Checking if the If statement is running or not but it isn't |
Hello, What is happening is that the if
is checking if min(game.Workspace.Time.Minutes.Value
) is equals to 45 and sec(game.Workspace.Time.Seconds.Value
) is equals or more than 10, but the value will never change, cause it will only get it on start.
Fixed code:
01 | local randomsec = game.Workspace.Time.Wait.Value -- 'randomsec' and 'waitsecs' are the same values, so no need to 2 variables |
02 |
03 | game.Workspace.Time.Changed:Connect( function () |
04 | script.Parent.Purple.Time.Text.Text = game.Workspace.Time.Value |
05 | end ) |
06 |
07 | while true do |
08 | local added = game.Workspace.Time.Added.Value |
09 | local min = game.Workspace.Time.Minutes.Value |
10 | local sec = game.Workspace.Time.Seconds.Value |
11 | wait(waitsecs) |
12 | print ( "Check" ) -- Checking if the main While loop is working |
13 | if min = = 45 and sec > = 10 then |
14 | print ( "Extra" ) -- Checking if the If statement is running or not but it isn't |
15 | script.Parent.AddedTime.Disabled = false |