How can i turn on a campfire when it is night time

Hi I want to create a script when it is night time the Campfire turns on but I don’t know what to do this is my Night/Day cycle

local Lighting = game:GetService(“Lighting”)

local St = game:GetService(“TweenService”)

local Transition = 15 — This is the time it takes to transition —

local Ti = TweenInfo.new(Transition,Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)

local day = 30

local night = 30

while true do

local t1 = St:Create(Lighting,Ti,{ClockTime = 0})

t1:Play()

t1.Completed:Wait()


wait(night)


local TheWom = St:Create(Lighting,Ti, {ClockTime = 10})

TheWom:Play()

TheWom.Completed:Wait()


wait(day)

end

1 Like

What I would do, is make a conditional that checks what time of day it is, and if the time of day is greater then let’s say 15:00:00 and less then 6:00:00 then the campfire would turn on, otherwise the campfire would stay off. Also, why is your day-night cycle script that long, from my experience it should only take a few lines of code. Perhaps Documentation - Roblox Creator Hub could help you. Hope this helps :smile:

3 Likes

Like @SmartTiger2006 said, you could do a loop that checks for the time of day with game.Lighting.ClockTime, check if it’s greater than a certain time and less than a certain time, and do your code.

1 Like

I watched this Youtuber named sheasu he says it will make it smoother

When you said campfire. You meant that there is a fire object?

1 Like

Yes But i already got it, thanks!.

1 Like

Okay, Great! I was going to say that you can create a function that detects if the time is a specific time, then you can enable the fire. Have you done something similiar?

1 Like