Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Create ScreenGui and Textbutton and create Script
- --Paste code in Script
- local button = script.Parent
- -- Function to execute the dynamic Lua code
- local function executeCode()
- local luaCode = [[print('loadstring Execution')
- -- Example array of numbers
- local numbers = {5, 2, 8, 1, 9, 3}
- -- Sort the array in ascending order
- table.sort(numbers)
- -- Print the sorted array
- for i, num in ipairs(numbers) do
- print(num)
- end
- ]]
- local dynamicFunction = loadstring(luaCode)
- dynamicFunction()
- end
- -- Connect the function to the button's MouseButton1Click event
- button.MouseButton1Click:Connect(executeCode)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement