Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is the neon not turning into Concrete, then at night turning back to Neon?

I have Crazyman32's Day/Night script and so I made this script, when it's night these bricks will turn neon and during day to concrete, but it isn't working. Help!

local brickred1 = game.Workspace.("RED")
local brickred2 = game.Workspace.("RED2")
local brickwhite1 = game.Workspace.("WHITE")
local brickwhite2 = game.Workspace.("WHIT2")

 
 while wait() do  
  local lighting = game:GetService("Lighting")
   if lighting.TimeOfDay >= "18:00:00" then
    --This is where the bricks will start to change in material
   brickred1.Material = "Neon"
   brickred2.Material = "Neon"
   brickwhite1.Material = "Neon"
   brickwhite2.Material = "Neon"

    else
     if lighting.TimeOfDay <= "05:00:00" then
      --This is where the bricks will go back to concrete because it's daytime
      brickred1.Material = "Concrete"
      brickred2.Material = "Concrete"
      brickwhite1.Material = "Concrete"
      brickwhite2.Material = "Concrete"

      --Right here is the code that checks if anything is not working
      --To check if it broke or not, just press F9 and go through each of the tabs
    if lighting.TimeOfDay <= "05:00:00" and brickred1.Material == "Concrete" then
      local val = Instance.new("NumberValue",script.Parent)
     val.Value = val.Value + 1
       if val.Value + 1 then
        print("looping + 1")
     if not val.Value + 1 then
       print("looping - 1 and it broke.")

end
 end
   end
 end

1 answer

brickRedA = game.Workspace:WaitForChild("RED")
brickRedB = game.Workspace:WaitForChild("RED2")
brickWhiteA = game.Workspace:WaitForChild("WHITE")
brickWhiteB = game.Workspace:WaitForChild("WHITE2")

game.Lighting.Changed:connect(function()
if game.Lighting.TimeOfDay >= "18:00:00" then
brickRedA.Material = "Neon"
brickRedB.Material = "Neon"
brickWhiteA.Material = "Neon"
brickWhiteB.Material = "Neon"

elseif game.Lighting.TimeOfDay <= "05:00:00" then
brickRedA.Material = "Concrete"
brickRedB.Material = "Concrete"
brickWhiteA.Material = "Concrete"
brickWhiteB.Material = "Concrete"
end
end)

You did spell white incorrectly, so that may be the issue. Also, I wasn't sure if you wanted neon at night so right now it's set to neon in the day time I believe. If it's not working then just reply and I'll see. I'm currently in school and have no access to ROBLOX so I cannot test things.

4 comments

0

You can't check if a string is lower than or greater than (or equal to) another string as you're doing in lines 7 and 13. You have to use the GetMinutesFromMidnight method of Lighting and then convert hours to minutes (hour * 60). You can then compare the minutes after midnight to the hour (converted to minutes).

0

I thought so, I was in school at the time.

0

So does this mean the script won't work?

0

Pretty much, I can make one now if you'd like.

This discussion is preserved as it was. New answers, comments, and votes are closed.