Listener doesn't Detect Conditions Met

Hello!

I have created a lighting listener, but it doesn’t work at all. The code follows:

while true do
wait(0.1)
if time == 18
then
print(“Tweening”)
local tweenInfo = TweenInfo.new(60, Enum.EasingStyle.Linear,
Enum.EasingDirection.Out, 0, false, 0)
local tween = game:GetService(“TweenService”):Create(colorValue, tweenInfo, {Value =
Color3.fromRGB(91, 122, 380 )})
tween:Play()

	end

end

I already defined the values “colorValue”, and “time”
colorValue is the colorValue of the terrain, and time is game.Workspace.Lighting.ClockTime. Is there anything wrong with this line of code, and/or what can I do?
Thanks,

R3M1X

Edit- The script doesn’t appear indented, but it is in game

I’m guessing the issue here is that the clock time doesn’t ever hit exactly 18. This most definitely the case if you are tweening it. Instead try a >= 18 and then just throw a variable check on the other side to make sure it only happens once.

1 Like

Alright, I’ll let you know how it goes :slight_smile:

1 Like

After some debugging, I found out that something is fundamentally wrong with the loop. I put a print command right after the loop would start, but it didn’t print. I also tried using a couple of other loops, but nothing worked. I’m sure your method works, but the loops are the problem in this situation. How can I fix this?

R3M1X

I’d have to see what you’re doing, not sure why a while loop wouldn’t be firing. Especially since you don’t appear to be returning anywhere in the function.

1 Like

Actually just got it working! Thanks for your help.

R3M1X

1 Like

Think it was what you said right above this. I defined those values before the loop started so it would increase performance

Cool! Glad I could help!

why30charstho

1 Like