Hey guys, I am making a GUI, and the if statement is doing like it's not there.. It is normal script - including explorer photo and code
--Variables local Variables = game.Workspace.Variables Hours = Variables.TV_1SessionTime.Hours Minutes = Variables.TV_1SessionTime.Minutes --Setup local function SetTime() script.Parent.Time.Text = Hours.Value .. ":" .. Minutes.Value .. " ET" if script.Parent.Time.Text == '00:00 ET' or '0:00 ET' or '00:0 ET' then --<<IT IS FOR SOME REASON TRUE, EVEN WHEN IT IS NOT 00:00, 0:00 OR 00:0! script.Parent.Time.Text = "Error boi! No time." end end --Main code script.Parent.Visible = true SetTime() Hours.Changed:connect(SetTime) Minutes.Changed:connect(SetTime)
Thanks in advance.
I've had the same issues -- it's because Roblox is VERY picky.
You need to declare "if script.Parent.Time.Text == " behind every STRING.
Like this:
if script.Parent.Time.Text == '00:00 ET' or script.Parent.Time.Text == '0:00 ET' or script.Parent.Time.Text == '00:0 ET' then
I know the feels, I've encountered the same issue. I do not know exactly why the "if" statement can have certain variables as a "true" e.g. the strings presented in your "if" statement.
But yeah, if you don't want to type "script.Parent.Time.Text" 24/7, I'd define it before the if statement, like this:
local text = script.Parent.Time.Text if text == '00:00 ET' or text == '0:00 ET' or text == '00:0 ET' then
Also, sometimes Roblox has trouble with defining properties of an instance, so I usually just like to define the instance instead of the property like this:
local text = script.Parent.Time if text.Text == '00:00 ET' or text.Text == '0:00 ET' or text.Text == '00:0 ET' then
All 3 above should fix the problem.