My NPC wont move when I tell it to in scripts

I wrote this script meant to move an NPC 10-30 seconds after a light goes out but he never moves. Can somebody tell me what’s wrong and how to fix it?

Door = game.Workspace.DoorPos
DoorFront = game.Workspace.DoorFront
humanoid = script.Parent

Smile = script.Parent.Parent.Head.faces.Smile
Regular = script.Parent.Parent.Head.faces.Regular

if game.Workspace.Lights.Main.One.Light.SpotLight.Enabled == false then
	if game.Workspace.Lights.Main.One.Light.SpotLight.Enabled == false then
		script.Parent.Parent = game.Workspace

(There are no errors in the output)

I think the problem you have is that the code above will only ever run once (when the script is parented to the NPC), and it will never run again. And so, the lights are probably on when the code runs so the NPC never moves.

The solution to this is to make sure that this bit of code runs whenever the lights change. This can be done using the PropertyChangedSignal event.


function checkLightsOut()
-- put your logic for moving the NPC in here.

-- Connect an event that will call the checkLightsOut function whenever the 
-- 'Enabled' property on the spotlight changes.

So basically a RoemoteEvent every time (in the script the lights goes out) under all the code?

And in function checkLightsOut() I should put everything including the if then statements?