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

Script has no error but isn't running at all, nothing even shows in Script Performance??

Asked by 8 years ago
Edited 8 years ago

Following the Day/Night cycle tutorial, I decided to separate the statements that operate the Lamps from turning on and off depending on the day and the statements that cycles through Day and Night.

When I did that, the script doesn't work at all but it shows no error, there is nothing inside Script Performance either so I know it's not running.

The script is inside a part called "Lightpart" along with another child called "PointLight" which is a PointLight. The parent of Lightpart is a Model.

Lamp Operator... (Code that doesn't work)

if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then
    wait(1)
    script.Parent.Material = Enum.Material.Neon
    wait(1)
    script.Parent.PointLight.Enabled = true
end
if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
    wait(1)
    script.Parent.Material = Enum.Material.Plastic
    wait(1)
    script.Parent.PointLight.Enabled = false
end

Day/Night cycle... (Code that works)

lightPart = game.Workspace.Model.Lightpart
minutesafterMidnight = 0
while true do
    minutesafterMidnight = minutesafterMidnight + 5
    game.Lighting:SetMinutesAfterMidnight(minutesafterMidnight)
    wait(.1)
end

As for why I chose to separate those two codes, it's because I notice that the codes do not run independently from each other so whenever I add in a debounce in the Lamp Operator, the Day/Night cycle stops for that rebound to.

0
Is the first code on a loop, and why is it missing an end? Are the two code snippets in the same script, if so, while loops will stop the rest of the code from running because a script, unless used with certain methods, will essentially only do one thing at a time. User#11440 120 — 8y

1 answer

Log in to vote
1
Answered by
deris88 146
8 years ago

1st code does not work because it is no looped. If you launch game with the time game.Lighting:GetMinutesAfterMidnight() == 18 * 60 it will do stuff, since server is started and time is not game.Lighting:GetMinutesAfterMidnight() == 18 * 60 it won't work. You should add the first code into while wait() do loop :

while wait() do
  if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then
      wait(1)
      script.Parent.Material = Enum.Material.Neon
      wait(1)
      script.Parent.PointLight.Enabled = true
  if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
      wait(1)
      script.Parent.Material = Enum.Material.Plastic
      wait(1)
      script.Parent.PointLight.Enabled = false
  end
end

0
What is the wait() in while wait() do suppose to be if it has no value in it? Physosear 10 — 8y
0
It's the shortest time a wait function can wait. User#11440 120 — 8y
Ad

Answer this question