How do i detect the time

Which snippet are you talking about? The one linked or the new one I provided?

1 Like

Please behold of normal and functional code

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
        if game.Lighting.ClockTime == 6 then 
              -- despawn logic
        elseif game.Lighting.ClockTime == 18 then
              -- spawn logic
        end
end)

oh wait you edited it a 3rd time my bad

Yeah, lol. I’m replying too quickly. I’ll be more thorough next time. This thread is already 24 posts long O_o

1 Like

He already said his clock goes too fast for his system to work. So I put it within a specific timeframe; his other code was functional (admittedly, yours is much cleaner)

1 Like

Tysm it worked

jdskfyuhfjeiot7gy8ewruioiefjiohbdoi

Umm even if the time is going faster, this is more effective bc you dont loop over every frame (which is task.wait()) but only when the time changes, plus this is much much cleaner code

lmao never mind it only works for the first day

jiodawwaijdwaio

Oh. Not sure why that might happen. Using inspiration from @Pixeluted’s code:

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
	if game.Lighting.ClockTime >= 6 and game.Lighting.ClockTime <= 7 then
		local NextbotDay = game.Workspace:FindFirstChild("Nextbot")
		
		if NextbotDay then
			NextbotDay.Parent =  game.ServerStorage
			game.ReplicatedStorage.Days.Value = game.ReplicatedStorage.Days.Value + 1
		end
	end
		
	if game.Lighting.ClockTime >= 18 and game.Lighting.ClockTime <= 19 then
		local NextbotNight = game.ServerStorage:WaitForChild("Nextbot")
		NextbotNight.Parent = game.Workspace
	end
end)

If this doesn’t work, I’m stumped. I’m not 100% sure what could be causing this issue, other than something on your part.

1 Like

imma try pixeluted now

dlmkjbhuyewfjiogyuwjiosgvuesfkd

Please dont use this bad code before I get heart attack

What’s the issue? Why are you being so rude? I’m just trying to help :face_with_head_bandage:

1 Like

you are making the code longer and using more checks for no reason

I was rushing the code, I should’ve also used it for… OH MY GOSH THATS THE REASON ITS NOT WORKING. Okay, I think I have it…

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
	if game.Lighting.ClockTime >= 6 and game.Lighting.ClockTime <= 7 then
		local NextbotDay = game.Workspace:FindFirstChild("Nextbot")
		
		if NextbotDay then
			NextbotDay.Parent =  game.ServerStorage
			game.ReplicatedStorage.Days.Value = game.ReplicatedStorage.Days.Value + 1
		end
	end
		
	if game.Lighting.ClockTime >= 18 and game.Lighting.ClockTime <= 19 then
		local NextbotNight = game.ServerStorage:FindFirstChild("Nextbot")
		
		if NextbotNight then
			NextbotNight.Parent = game.Workspace
		end
	end
end)
2 Likes

Very unfunctional code (it didnt work :frowning:

imma check urs rn

sdjfhfeauiyvaesp

I wonder why this was deleted :eyes:

1 Like

It works for at least 2 days.

dahwjjioaywi

1 Like

Fine if you are unable to copy paste your own code in here

local NextBotInStorage = game.ServerStorage.NextBot -- No need for findfirstchild

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
        if game.Lighting.ClockTime == 6 then 
              -- despawn logic
             workspace.NextBot:Destroy()
        elseif game.Lighting.ClockTime == 18 then
              -- spawn logic
              local nextBotCloned = NextBotInStorage:Clone() -- clone it because if you dont it will work only one night
              nextBotCloned.Parent = workspace
        end
end)

THANK YOU SO MUCH!

wdakniuadwok

it works 100%