Hi. I'm trying to make a real-time clock for use in my game, but it says
Players.LuckyCGT.PlayerGui.Clock.LocalScript:3: ')' expected near ','
This is the code:
01 | while wait() do |
02 | local Data = os.date( "t" ) |
03 | local Months = ( "Jan" , "Feb" , "Mar" , "Apr" , "May" , "Jun" , "Jul" , "Aug" , "Sep" , "Oct" , "Nov" , "Dec" ) |
04 | local Date = script.Parent:WaitForChild( "Date" ) |
05 | local Time = script.Parent:WaitForChild( "Time" ) |
06 | for i,v in pairs (Months) do |
07 | if Data.month = = i then |
08 | Date.Text = v.. "/" ..Data.day.. "/" ..Data.year |
09 | end |
10 | end |
11 | Time.Text = Data.hour.. "t" ..Data.min.. "t" ..Data.sec |
12 | end |
The comma that is "broken" is the one between "Jan" and "Feb". I've tried putting a bracket where the comma is on line 3, but that still doesn't do anything.
Any help would be appreciated.
It appears you want to make Months
into a table. To do this you must use curly braces { }
and not parenthesis. Below is the modified script
01 | while wait() do |
02 | local Data = os.date( "t" ) |
03 | local Months = { "Jan" , "Feb" , "Mar" , "Apr" , "May" , "Jun" , "Jul" , "Aug" , "Sep" , "Oct" , "Nov" , "Dec" } |
04 | local Date = script.Parent:WaitForChild( "Date" ) |
05 | local Time = script.Parent:WaitForChild( "Time" ) |
06 | for i,v in pairs (Months) do |
07 | if Data.month = = i then |
08 | Date.Text = v.. "/" ..Data.day.. "/" ..Data.year |
09 | end |
10 | end |
11 | Time.Text = Data.hour.. "t" ..Data.min.. "t" ..Data.sec |
12 | end |