Error <name> expected near "if"
10,132
The function is missing a name. Lua reads to the next line looking for the function's name and gets confused when it finds an if
statement.
Also, the first if statement should be if active == 0 then
because ==
is the comparison operator.
Author by
Admin
Updated on June 04, 2022Comments
-
Admin almost 2 years
Hi this is my first lua code but I get a error pls fix it thx in advanced if you do get this working. I have a feeling its a small thing I'm missing.
class 'Autochat' TalkTimer = Timer() local TalkDelay = 1 -- in minutes local active = 1 function if active = 0 then return end if active ~= "0" then if(TalkTimer:GetSeconds() > (60 * timeDelay)) then Chat:Broadcast("Hi the admin is offline.", Colors(0, 255, 0)) TalkTimer:Restart() end end end Autochat = Autochat()
-
Oliver over 9 yearsalso the
if active ~= "0"
should beif active ~= 0
sinceactive
is a number, and thetimeDelay
should probably be replaced byTalkDelay