Getpropertychangedsignal not working

had a script and GetPropertyChangedSignal isn’t working after certain time. It works and changes when clockTime goes 6 but when it goes 18 it doesn’t even change at all

-- ServerScript

LightningService:GetPropertyChangedSignal("ClockTime"):Connect(function()
	if LightningService.ClockTime >= 6 then
		for _, Out_Lights in CollectionService:GetTagged("OutsideLights") do
			if Out_Lights.ClassName == "SpotLight" then
				Out_Lights.Enabled = false
			end
		end
		
		for _, Part_Lights in CollectionService:GetTagged("Lights_Parts") do
			if Part_Lights.ClassName == "Beam" then
				Part_Lights.Enabled = false
			end
			
			if Part_Lights.ClassName == "Part" then
				Part_Lights.Color = Color3.new(0, 0, 0)
			end
		end
	elseif LightningService.ClockTime >= 18 then
		for _, Out_Lights in CollectionService:GetTagged("OutsideLights") do
			if Out_Lights.ClassName == "SpotLight" then
				Out_Lights.Enabled = true
			end
		end
		
		for _, Part_Lights in CollectionService:GetTagged("Lights_Parts") do
			if Part_Lights.ClassName == "Beam" then
				Part_Lights.Enabled = false
			end
			
			if Part_Lights.ClassName == "Part" then
				Part_Lights.Color = Color3.new(1, 1, 1)
			end
		end
	end
end)

print before the if statement:

-- ServerScript

LightningService:GetPropertyChangedSignal("ClockTime"):Connect(function()
        print("Changed!")
	if LightningService.ClockTime >= 6 then
		for _, Out_Lights in CollectionService:GetTagged("OutsideLights") do
			if Out_Lights.ClassName == "SpotLight" then
				Out_Lights.Enabled = false
			end
		end
		
		for _, Part_Lights in CollectionService:GetTagged("Lights_Parts") do
			if Part_Lights.ClassName == "Beam" then
				Part_Lights.Enabled = false
			end
			
			if Part_Lights.ClassName == "Part" then
				Part_Lights.Color = Color3.new(0, 0, 0)
			end
		end
	elseif LightningService.ClockTime >= 18 then
		for _, Out_Lights in CollectionService:GetTagged("OutsideLights") do
			if Out_Lights.ClassName == "SpotLight" then
				Out_Lights.Enabled = true
			end
		end
		
		for _, Part_Lights in CollectionService:GetTagged("Lights_Parts") do
			if Part_Lights.ClassName == "Beam" then
				Part_Lights.Enabled = false
			end
			
			if Part_Lights.ClassName == "Part" then
				Part_Lights.Color = Color3.new(1, 1, 1)
			end
		end
	end
end)

it works, just like I told you. However, when the property tries to detect if the ClockTime is greater than 18 it doesn’t work and still keeps printing Time is Morning.

Already checked if there’s Time is night in the Output but there currently isnt one.

this is how the script looked like rn (no changes added just the print)

And yes the Print Changed gives results as well.


huh
maybe you forgot to put <= 18 in the 6 clock???

I’ll try and see if lesser than 18 would do the trick

yup it does


the lol x4 was when i didnt add the <18

gimme credits man
:sob:
and no its not a getproperty changed signal issue, its just a misscode issue

omg this worked FINALLY! I knew it has something to do with detecting if its lesser or greater bc I felt that the first line when detecting if clocktime is greater than 6 get’s overlapped a lot with clocktime greater than 18

No. YOu did first. I didn’t see it because I was doing it on Roblox Studio.

@iiNathxnism The reason why you need to check if it is less than 18 is bc you were checking if clock time was greater or equal to 6, and 18 is greater than 6, consequently resulting in true all-time.

I’m glad you’ve solved your problem! Any more helps, feel free to contact here!

2 Likes

yup that’s what I realized as well. Thanks to the both of you for wanting to help me out :heavy_heart_exclamation:

2 Likes

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