You can change items
-- CONFIGURATION local display_number = {1, 2, 3, 4} local items = {12499, 11600, 11667, 11668} local pictures = {"1012499", "1011600", "1011667", "1011668"} local button_id = "7369828431314806377_12" -- Button ID local image_element_id = "7369828431314806377_10" -- Image element ID local ui_page_id = "7369828431314806377" -- UI page ID local spin_count = 15 -- Number of spin animation loops -- SPIN FUNCTION function spin(e) if e.uielement == button_id then local repeat_time = 0 local random_index local item_id local picture_id repeat random_index = display_number[math.random(#display_number)] item_id = items[random_index] picture_id = pictures[random_index] Customui:setTexture(e.eventobjid, ui_page_id, image_element_id, picture_id) Trigger:wait(0.1) repeat_time = repeat_time + 1 until repeat_time == spin_count Player:gainItems(e.eventobjid, item_id, 1, 1) end end -- REGISTER EVENT ScriptSupportEvent:registerEvent("UI.Button.Click", spin)
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.
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