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!
l = game:service("Lighting") r = game:service("RunService") while true do --Time and day if l.TimeOfDay = "07:30:00" then game.Workspace.Saito.humanoid.Health = 0 wait(.2) end end
This is an error that Output should have caught and been telling you. You use a double equal sign to do comparisons:
if l.TimeOfDay == "07:30:00" then
Also, I suggest tabbing your code properly:
l = game:service("Lighting") r = game:service("RunService") while true do --Time and day if l.TimeOfDay == "07:30:00" then game.Workspace.Saito.humanoid.Health = 0 end wait(.2) --The loop will crash if the condition is false and only waits inside the loop. end
I also suggest looking into the GetMinutesAfterMidnight
method, which is a bit more useful than TimeOfDay