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

Help with TimeOfDay script?

Asked by
Xl5Xl5 65
9 years ago

So what I am trying to do is when the TimeOfDay is 07:30:00, Saito (NPC) dies at that time, and will day everytime it hits 07:30:00. I kept changing small things from health = 0 to breakjoints lines. I am not entirely sure what I am doing wrong, but the NPC doesn't die at that time. Also this script lies within Workspace

please help! thank you!

01l = game:service("Lighting")
02r = game:service("RunService")
03 
04while true do
05--Time and day
06if l.TimeOfDay = "07:30:00" then
07game.Workspace.Saito.humanoid.Health = 0
08wait(.2)
09end
10end

1 answer

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

This is an error that Output should have caught and been telling you. You use a double equal sign to do comparisons:

1if l.TimeOfDay == "07:30:00" then

Also, I suggest tabbing your code properly:

01l = game:service("Lighting")
02r = game:service("RunService")
03 
04while true do
05    --Time and day
06    if l.TimeOfDay == "07:30:00" then
07        game.Workspace.Saito.humanoid.Health = 0
08    end
09    wait(.2) --The loop will crash if the condition is false and only waits inside the loop.
10end

I also suggest looking into the GetMinutesAfterMidnight method, which is a bit more useful than TimeOfDay

Ad

Answer this question