Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Part of the code works in one spot and not the other, how do I fix this?

Asked by 8 years ago
Light = game.Workspace.Lamp.LightPart
Time = 0

while true do
    Time = Time+4
    game.Lighting:SetMinutesAfterMidnight(Time)
    wait(.1)

    if game.Lighting:GetMinutesAfterMidnight == 6 * 60 then
        Light.Material = Enum.Material.Plastic
        Light.PointLight.Enabled = false
    end 
    if game.Lighting:GetMinutesAfterMidnight == 18 * 60 then
        Light.Material = Enum.Material.Neon
        Light.PointLight.Enabled = true
    end
end

That's the code I'm using to turn a lamp on and of at certain times in the day but in the first "if then" statement "==" cause an error because it expects a ( or { how do I fix this (And yes the is the Wiki's Tutorial day/night script).

1 answer

Log in to vote
1
Answered by 8 years ago

You need to write "GetMinutesAfterMidnight()" because it is a function, and you always put open and close brackets after the name when calling it. Inside the brackets, you would pass it an argument (Either nothing or Time in your case), so the function knows what its doing.

0
Then why did it work in the 2nd function? CGawesome3 0 — 8y
0
What does the output say? iFireLazer 35 — 8y
Ad

Answer this question