Bad lexical cast: source type value could not be interpreted as target

Reproduction Steps

Output

System Information:
Intel Core i9 9900K
16GB DDR5 RAM
Nvidia GeForce RTX 2080Ti

All beta features enabled

Repro

for hour = 1, 5 do 
      for minute = 1, 30 do 
           game:GetService("Lighting").TimeOfDay = hour + (minute / 100)
     end
end

The file will error but also output a lexical error, likely from the analysis.

Expected Behavior

Luau doesn’t output a lexical error.

Actual Behavior

Luau outputs the error in the report name.

Issue Area: Studio
Issue Type: Other
Impact: Low
Frequency: Very Rarely
Date First Experienced: 2022-12-17 00:12:00 (+06:30)
Date Last Experienced: 2022-12-17 00:12:00 (+06:30)

TimeOfDay is a string that looks sort of like a timestamp. What you wanted is probably SetMinutesAfterMidnight.

That being said, this error message could definitely be improved to tell you that. I’ll file a feature request internally for that.

2 Likes

You could also use ClockTime which is in hours.

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