How do I make a function happen when ClockTime is more than 18

Hello guys so i tried to do a function that when ClockTime > 18 a ProximityPrompt will be enabled but i dunno how to make it, Can anyone help? Ive tried something in my own but it didnt worked
Ekran görüntüsü 2024-04-03 070115

The if statement you wrote will only run once: at the time the script initially starts.

You’d want to connect a function to the Lighting service to see whenever the ClockTime changed:

local lighting = game:GetService("Lighting")

local function onClockTimeChanged()
   -- a > b returns a boolean (true or false), so you can write the statement like this
   ProximityPrompt.Enabled = lighting.ClockTime > 18
end

onClockTimeChanged() -- Call the function here just to do an initial check when the script starts

-- This will run the function every time the ClockTime property on Lighting changes or is modified
lighting:GetPropertyChangedSignal("ClockTime"):Connect(onClockTimeChanged)
1 Like

Thank you so much dude, You resolved my issue

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.