Flashlight script not working

Hi all
i am making a horror game in which a player can only turn on there flashlight at certain time of day.
But when i try to implement this into the script it is not working.I really don’t know why this is happening
i was wondering if any one can help me.

Here’s the script

local mouse = game.Players.LocalPlayer:GetMouse()

function Light()
	local player = game.Players.LocalPlayer
	local playerChar = player.Character
	local playerLight = playerChar.Head:FindFirstChild("Light")
	if playerLight then
		local light = Instance.new("SurfaceLight",playerChar:FindFirstChild("Head"))
		light.Name = "Light"
		light.Range = 60
		light.Angle = 60
		light.Shadows = true
		light.Brightness = 5

if game.Lighting.TimeOfDay == "13:00:00" then

		key = key:lower()
		if key == "f" then

and would anything happen if remove


Enclose your if statement inside a function which runs when game.Lighting:GetPropertyChangedSignal("TimeOfDay") fires.

Please don’t post the same topic twice, you asked this exact question a while ago and got a good answer.
Your script is only successful at exactly “13:00:00”, or 1 o’clock in the afternoon. Then it allows a change if the player clicks their mousebutton.

You need to make it function every time they click their mousebutton and check to see if the GetMinutesAfterMidnight (not TimeOfDay) is in a range where it would be useful. If you need it from 13:00 to 14:00 then use this:

mouse.KeyDown:connect(function(key) -- see the note below
if game.Lighting.GetMinutesAfterMidnight() > 13 * 60 or game.Lighting.GetMinutesAfterMidnight() > 14 * 60 then
    -- allow flashlight to turn on with mouseclick, or use UserInputService to see if the player clicks the letter F.

Here’s a good tutorial about day/night cycle streetlamps: Day/Night Cycle: Street Light - YouTube You just need to figure out how you want the light to be enabled in those time parameters. Here’s a link to UserInputService | Roblox Creator Documentation.

Is the SurfaceLight being attached to the correct face of the Part?

ok thank you and sorry i was just really desperate to get the script working