Im trying a kind of lamp to bright when its nightime (my game has it) but this doesnt work , help!
if game.Lighting.ClockTime = 18 then script.Parent.Material = [Neon] end
Hello!
First of all, you should be constantly checking if it is nighttime, about every second or minute, depending on how fast your day turns out to be.
You can use a while
loop for this.
Next, you will want to check if the value is 18 or later, you can use >= 18
for this, as it will check if it is 18 or higher.
Next, you want to change it to the Neon material, then you will have to use Enum.Material.Neon
.
Now, let's turn this logic into code.
local Lighting = game:GetService("Lighting"); -- Our while loop while true do -- Checking if the time is 18 or more. if Lighting.ClockTime >= 18 then -- Let's change the lamp's material to Neon! script.Parent.Material = Enum.Material.Neon; else -- Change it to SmoothPlastic if it isn't late :D script.Parent.Material = Enum.Material.SmoothPlastic; end wait(1) -- Waits a second before continuing end
I think the problem is that you need to put the material in quotes, like this:
if game.Lighting.ClockTime = 18 then script.Parent.Material = "Neon" end
The issue you had with your script is that you are not supposed to put a material in brackets like that unless you need to use a parameter in a function or a variable when you are trying to reference something like if I were to do this
local Key = "J" local Thing = Enum.KeyCode[Key]
I hope this helps. If it does not, it is probably because you are not showing us enough of your code. Accept if this helps. Thank you.