urabigfatnoob

simplified radical calc

Nov 20th, 2017
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.53 KB | None | 0 0
  1. wait(.2)
  2. plr = game.Players.LocalPlayer;
  3. plrgui = plr:WaitForChild('PlayerGui');
  4. screengui = plrgui:WaitForChild('ScreenGui');
  5. frame = screengui:WaitForChild('Frame');
  6. input = frame:WaitForChild('TextBox');
  7. answer = frame:WaitForChild('TextLabel');
  8. check = frame:WaitForChild('TextButton');
  9. print('uis loaded');
  10. debounce = false;
  11. squares = {};
  12. other = {};
  13. for i = 2,2000 do
  14.     table.insert(squares,i*i);
  15. end;
  16.  
  17. check.MouseButton1Click:connect(function()
  18.     if debounce == false then
  19.         debounce = true;
  20.         perfect = false;
  21.         local val = tonumber(input.Text);
  22.         for i = 1,1999 do
  23.             if val == squares[i] then
  24.                 perfect = true;
  25.                 answer:TweenSize(UDim2.new(0,200,0,0),'Out','Bounce',1,false);
  26.                 wait(1);
  27.                 answer:TweenSize(UDim2.new(0,200,0,50),'Out','Bounce',1,false);
  28.                 answer.Text = val^.5;
  29.                 break;
  30.             elseif val%squares[i] == 0 then
  31.                 table.insert(other,squares[i]);
  32.             end;
  33.         end;
  34.         print(perfect);
  35.         if #other == 0 and perfect == false then
  36.             answer:TweenSize(UDim2.new(0,200,0,0),'Out','Bounce',1,false);
  37.             wait(1);
  38.             answer:TweenSize(UDim2.new(0,200,0,50),'Out','Bounce',1,false);
  39.             answer.Text = 'Already Simplified';
  40.         elseif perfect == false then
  41.             table.sort(other);
  42.             big = (other[#other]);
  43.             out = (other[#other])^.5;
  44.             inside = val/big;
  45.             print(inside);
  46.             answer:TweenSize(UDim2.new(0,200,0,0),'Out','Bounce',1,false);
  47.             wait(1);
  48.             answer:TweenSize(UDim2.new(0,200,0,50),'Out','Bounce',1,false);
  49.             answer.Text = (out..'√'..inside);
  50.         end;
  51.     end;
  52.     debounce = false;
  53. end);
  54.  
  55. --test
Advertisement
Add Comment
Please, Sign In to add comment