Table of Contents

ROTATION LUCK

I. Design UI

You can change items

II. Diagram

III. Script

local display_number = {1, 2, 3, 4}
local items = {12499, 11600, 11667, 11668} -- fill your items here
local pictures = {"1012499", "1011600", "1011667", '1011668'} -- fill your pictures following the items here here
function spin(e)
  		if e.uielement == '7369828431314806377_12' then --- change your button
      		local repeat_time = 0 
      		local random_number
     	 		local items_spin
      		local picture_spin
      			repeat
          				random_number = display_number[math.random(#display_number)]
          				items_spin = items[random_number]
          				picture_spin = pictures[random_number]
          				repeat_time = repeat_time + 1
           	 			Customui:setTexture(e.eventobjid, [[7369828431314806377]],[[7369828431314806377_10]], picture_spin) --- change your element
          				Trigger:wait(0.1)
      			until repeat_time == nil --- fill your time here
      		Player:gainItems(e.eventobjid, items_spin, 1, 1)
  			end
	end
ScriptSupportEvent:registerEvent('UI.Button.Click', spin)

IV. Explaination

1. Initialization of Arrays:

local display_number = {1, 2, 3, 4}
local items = {12499, 11600, 11667, 11668} -- fill your items here
local pictures = {"1012499", "1011600", "1011667", '1011668'} -- fill your pictures following the items here here

2. Spin Function

function spin(e)
  if e.uielement == '7369828431314806377_12' then
      local repeat_time = 0 
      local random_number
      local items_spin
      local picture_spin
      repeat
          random_number = display_number[math.random(#display_number)]
          items_spin = items[random_number]
          picture_spin = pictures[random_number]
          repeat_time = repeat_time + 1
          Customui:setTexture(e.eventobjid, [[7369828431314806377]],[[7369828431314806377_10]], picture_spin)
          Trigger:wait(0.1)
      until repeat_time == nil --- fill your time here
      Player:gainItems(e.eventobjid, items_spin, 1, 1)
  end
end

3. Event Registration:

ScriptSupportEvent:registerEvent('UI.Button.Click', spin)

This line registers the spin function to be called whenever the UI.Button.Click event occurs.

V. Summary of the Script

Initialization:

Spin Function:

Event Registration:

Adjustments Needed Define Loop End Condition: Replace until repeat_time == nil with a proper condition, such as until repeat_time == 10 (or any other number based on how many spins you want). Ensure UI Element IDs are Correct: Verify that the UI element IDs match those in your actual project.


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