• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Error in Script of Random Text

FabianoBN

l|¬¬"|l
Joined
Jan 23, 2009
Messages
745
Reaction score
22
Location
Goias - Brazil
TFS 0.3.7_SVN

This Script is to give a random text and if the first text leaving it removes the item.

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local text = {"Ok!", "I go!", "No No No."}
if text[1,#text] ~= nil then
local texts = text[1, #text][math.random(#text[1, #text])]
if texts == text[1] then
doRemoveItem(cid, itemEx.uid,1)
doPlayerSendTextMessage(toPosition, "Break", TEXTCOLOR_ORANGE) 
else
doPlayerSendTextMessage(toPosition, ""..random.."", TEXTCOLOR_ORANGE) 
end
return TRUE
end

But I get this error:
Lua:
ERROR: untitled.lua:3: ']' expected near ','

This is the line:
Lua:
if text[1,#text] ~= nil then

And this line also returns the error:
Lua:
local texts = text[1, #text][math.random(#text[1, #text])]
 
Last edited:
Back
Top