Advertisement
LikeRampage

CHATGPT Loadstring execute code Roblox Studio

Aug 12th, 2023 (edited)
1,305
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 1 0
  1. -- Create ScreenGui and Textbutton and create Script
  2. --Paste code in Script
  3. local button = script.Parent
  4.  
  5. -- Function to execute the dynamic Lua code
  6. local function executeCode()
  7.     local luaCode = [[print('loadstring Execution')
  8.     -- Example array of numbers
  9. local numbers = {5, 2, 8, 1, 9, 3}
  10.  
  11. -- Sort the array in ascending order
  12. table.sort(numbers)
  13.  
  14. -- Print the sorted array
  15. for i, num in ipairs(numbers) do
  16.     print(num)
  17. end
  18.     ]]
  19.     local dynamicFunction = loadstring(luaCode)
  20.     dynamicFunction()
  21. end
  22.  
  23. -- Connect the function to the button's MouseButton1Click event
  24. button.MouseButton1Click:Connect(executeCode)
Tags: loadstring
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement