plytalent

DrawUI

Feb 16th, 2022 (edited)
1,054
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.21 KB | None | 0 0
  1. assert(rconsoleinfo, 'exploit not supported')
  2. assert(Drawing, 'exploit not supported')
  3. if _G.DrawUI then
  4.     return _G.DrawUI
  5. end
  6. local player = game:GetService("Players").LocalPlayer
  7. local mouse = player:GetMouse()
  8. local UserInputService = game:GetService("UserInputService")
  9.  
  10. local DrawUI = {
  11.     mouse_down = false,
  12.     drawinglist = {},
  13.     mouse_down_funcs = {}
  14. }
  15.  
  16. function DrawUI:Count_Newline(str)
  17.     local lines = 1
  18.     for i = 1, #str do
  19.         local c = str:sub(i, i)
  20.         if c == '\n' then
  21.             lines = lines + 1
  22.         end
  23.     end
  24.     return lines
  25. end
  26.  
  27. function DrawUI:Bind_Func_to_MouseDown(drawingobject,func)
  28.     DrawUI.mouse_down_funcs[drawingobject] = func
  29. end
  30.  
  31. function DrawUI:MakeDraggable(drawingobject)
  32.     DrawUI.mouse_down_funcs[drawingobject] = (function(drawingobject)
  33.         local drawingobject = drawingobject
  34.         local MouseLocation = GetMouseLocation()
  35.         local delta = drawingobject.Position - MouseLocation
  36.         while DrawUI.mouse_down do
  37.             game:GetService("RunService").RenderStepped:Wait()
  38.             drawingobject.Position = GetMouseLocation() + delta
  39.         end
  40.     end)
  41. end
  42.  
  43. mouse.Button1Down:Connect(function()
  44.     DrawUI.mouse_down = true
  45.     for drawingobject,func in pairs(DrawUI.mouse_down_funcs) do
  46.         if IsMouseOverDrawing(drawingobject) and drawingobject.Visible then
  47.             func(drawingobject)
  48.         end
  49.     end
  50. end)
  51. mouse.Button1Up:Connect(function()
  52.     DrawUI.mouse_down = false
  53. end)
  54.  
  55. function DrawUI:synTextLabel()
  56.     local drawingobject = Drawing.new("Text")
  57.     DrawUI.drawinglist[#DrawUI.drawinglist+1] = drawingobject
  58.     drawingobject.Text = "Place"
  59.     drawingobject.Size = 24
  60.     drawingobject.Center = false
  61.     drawingobject.Outline = true
  62.     drawingobject.Color = Color3.new(255/255, 0/255, 0/255)
  63.     drawingobject.OutlineColor = Color3.new(0, 0, 0)
  64.     return drawingobject
  65. end
  66.  
  67. function DrawUI:synTextButton()
  68.     local drawingobject = Drawing.new("Square")
  69.     local text = synTextLabel()
  70.     DrawUI.drawinglist[#DrawUI.drawinglist+1] = drawingobject
  71.     drawingobject.Size = Vector2.new(200,100)
  72.     drawingobject.Color = Color3.new(.75, .75, .75)
  73.     drawingobject.Filled = true
  74.     spawn(function()
  75.             while true do
  76.             wait()
  77.             text.Center = true
  78.             text.Position = Vector2.new((drawingobject.Position.X+drawingobject.Size.X/2)-text.Text:len()/2 ,(drawingobject.Position.Y + drawingobject.Size.Y/2)-text.Size/2)
  79.             game:GetService("RunService").RenderStepped:Wait()
  80.         end
  81.     end)
  82.     return drawingobject ,text
  83. end
  84.  
  85. function GetMouseLocation()
  86.     return UserInputService:GetMouseLocation();
  87. end
  88.  
  89. function IsMouseOverDrawing(Drawing, MousePosition)
  90.     local TopLeft = Drawing.Position;
  91.     local BottomRight
  92.     if Drawing.Text then
  93.         BottomRight = Vector2.new(Drawing.Position.X + #Drawing.Text, Drawing.Position.Y+(DrawUI:Count_Newline(Drawing.Text)*Drawing.Size))
  94.     else
  95.         BottomRight = Drawing.Position + Drawing.Size;
  96.     end
  97.     local MousePosition = MousePosition or GetMouseLocation();
  98.  
  99.     return MousePosition.X > TopLeft.X and MousePosition.Y > TopLeft.Y and MousePosition.X < BottomRight.X and MousePosition.Y < BottomRight.Y;
  100. end
  101. _G.DrawUI = DrawUI
  102. return DrawUI
Add Comment
Please, Sign In to add comment