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:
local added = game.Workspace.Time.Added.Value local waitsecs = game.Workspace.Time.Wait.Value local min = game.Workspace.Time.Minutes.Value local sec = game.Workspace.Time.Seconds.Value local randomsec = game.Workspace.Time.Wait.Value game.Workspace.Time.Changed:Connect(function() script.Parent.Purple.Time.Text.Text = game.Workspace.Time.Value end) while true do wait(waitsecs) print("Check") -- Checking if the main While loop is working if min == 45 and sec >= 10 then print("Extra") -- Checking if the If statement is running or not but it isn't script.Parent.AddedTime.Disabled = false script.Parent.Purple.Time.Added.AddedT.Text = "+" .. added .. "'" script.Parent.Purple.AddedTimeValue.Text = "+" .. added .. "'" end if min == 45 + added and sec >= randomsec then print("End") wait(2) script.Parent.OutAnimation.Disabled = false script.Parent.InAnimation.Disabled = true wait(.8) break end end
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:
local randomsec = game.Workspace.Time.Wait.Value -- 'randomsec' and 'waitsecs' are the same values, so no need to 2 variables game.Workspace.Time.Changed:Connect(function() script.Parent.Purple.Time.Text.Text = game.Workspace.Time.Value end) while true do local added = game.Workspace.Time.Added.Value local min = game.Workspace.Time.Minutes.Value local sec = game.Workspace.Time.Seconds.Value wait(waitsecs) print("Check") -- Checking if the main While loop is working if min == 45 and sec >= 10 then print("Extra") -- Checking if the If statement is running or not but it isn't script.Parent.AddedTime.Disabled = false script.Parent.Purple.Time.Added.AddedT.Text = "+" .. added .. "'" script.Parent.Purple.AddedTimeValue.Text = "+" .. added .. "'" end if min == 45 + added and sec >= randomsec then print("End") wait(2) script.Parent.OutAnimation.Disabled = false script.Parent.InAnimation.Disabled = true wait(.8) break end end