Table of Contents

Lucky Number

I. Diagram

II. Design

You need to add a input box. Player enter string in the input box

III. Script

local _input_string = nil --- fill your element	
function game(event) 
	if _input_string == event.uielement then
      	local variable_lucky_number = math.random(0, 100)
      	if string.find(event.content, variable_lucky_number) then
          		Chat:sendSystemMsg("Congratulation! Your lucky number is: " .. variable_lucky_number)
      	else
          		Chat:sendSystemMsg("Error Code " .. variable_lucky_number)
      	end
  		end
end
ScriptSupportEvent:registerEvent('UI.LostFocus',game)

IV. Explanation

Line 1:

local _input_string = nil --- fill your element	

Line 2 - 10:

function game(event) 
	if _input_string == event.uielement then
      	local variable_lucky_number = math.random(0, 100)
      	if string.find(event.content, variable_lucky_number) then
          		Chat:sendSystemMsg("Congratulation! Your lucky number is: " .. variable_lucky_number)
      	else
          		Chat:sendSystemMsg("Error Code " .. variable_lucky_number)
      	end
  		end
end

Line 5:

      if string.find(event.content, variable_lucky_number) then
      

The last line:

ScriptSupportEvent:registerEvent('UI.LostFocus',game)

If you have any questions about Developer Tools, feel free to join our official discord server Mini World Global DEV discord