DrawingJhon

Log smartboard

Jul 12th, 2022 (edited)
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.99 KB | None | 0 0
  1. local sg = Instance.new("ScreenGui")
  2. sg.Name = "LogNotepad"
  3. local main = Instance.new("Frame", sg)
  4. main.Name = "Main"
  5. main.BackgroundColor3 = Color3.fromRGB(10, 10, 10)
  6. main.BackgroundTransparency = 0.4
  7. main.Size = UDim2.new(0, 400, 0, 400)
  8. main.BorderSizePixel = 0
  9. main.Position = UDim2.new(0.5, -200, 0.5, -200)
  10. local scroll = Instance.new("ScrollingFrame", main)
  11. scroll.CanvasSize = UDim2.new()
  12. scroll.AnchorPoint = Vector2.new(0.5, 0)
  13. scroll.Position = UDim2.new(0.5, 0, 0, 25)
  14. scroll.Size = UDim2.new(1, -10, 1, -30)
  15. scroll.BorderSizePixel = 0
  16. scroll.BackgroundColor3 = Color3.fromRGB(10, 10, 10)
  17. scroll.BackgroundTransparency = 0.4
  18. scroll.ScrollBarThickness = 5
  19. local tb = Instance.new("TextBox", scroll)
  20. tb.Name = "Editor"
  21. tb.AnchorPoint = Vector2.new(0.5, 0.5)
  22. tb.Position = UDim2.new(0.5, 0, 0.5, 0)
  23. tb.Size = UDim2.new(1, -6, 1, -6)
  24. tb.BorderSizePixel = 0
  25. tb.Font = "SourceSans"
  26. tb.BackgroundTransparency = 1
  27. tb.TextXAlignment = "Left"
  28. tb.TextYAlignment = "Top"
  29. tb.TextSize = 15
  30. tb.TextColor3 = Color3.new(1, 1, 1)
  31. tb.ClearTextOnFocus = false
  32. tb.MultiLine = true
  33. tb.TextWrapped = true
  34. tb.Text = ""
  35. tb.TextEditable = false
  36. local button = Instance.new("TextButton", main)
  37. button.AnchorPoint = Vector2.new(1, 0)
  38. button.Position = UDim2.new(1, -5, 0, 0)
  39. button.Size = UDim2.new(0, 30, 0, 20)
  40. button.BorderSizePixel = 0
  41. button.BackgroundColor3 = Color3.fromRGB(255, 10, 10)
  42. button.BackgroundTransparency = 0.4
  43. button.Text = "X"
  44. button.TextColor3 = Color3.new(1, 1, 1)
  45. local minimize = Instance.new("TextButton", main)
  46. minimize.Name = "Minimize"
  47. minimize.AnchorPoint = Vector2.new(1, 0)
  48. minimize.Position = UDim2.new(1, -35, 0, 0)
  49. minimize.Size = UDim2.new(0, 30, 0, 20)
  50. minimize.BorderSizePixel = 0
  51. minimize.BackgroundColor3 = Color3.fromRGB(10, 10, 10)
  52. minimize.BackgroundTransparency = 0.3
  53. minimize.Text = "-"
  54. minimize.TextColor3 = Color3.new(1, 1, 1)
  55. local clear = Instance.new("TextButton", main)
  56. clear.Name = "Clear"
  57. clear.AnchorPoint = Vector2.new(1, 0)
  58. clear.Position = UDim2.new(1, -70, 0, 0)
  59. clear.BorderSizePixel = 0
  60. local title = Instance.new("TextLabel", main)
  61. title.Name = "Title"
  62. title.TextXAlignment = "Left"
  63. title.Position = UDim2.new(0, 8, 0, 2)
  64. title.Size = UDim2.new(0, 80, 0, 20)
  65. title.TextColor3 = Color3.new(1, 1, 1)
  66. title.BackgroundTransparency = 1
  67. title.Text = "Notepad"
  68. title.Font = "SourceSans"
  69. title.TextSize = 16
  70.  
  71. sg.Parent = game:GetService("CoreGui")
  72.  
  73. -- Variables
  74. local player = game:GetService("Players").LocalPlayer
  75. local mouse = player:GetMouse()
  76. local uis = game:GetService("UserInputService")
  77.  
  78. -- Draggable
  79. local tweenEffect = false
  80.    
  81. local mouseButton1, Touch = Enum.UserInputType.MouseButton1, Enum.UserInputType.Touch
  82. local pressing = false
  83.  
  84. local function inputMouse(input)
  85.     return input.UserInputType == mouseButton1 or input.UserInputType == Touch
  86. end
  87.  
  88. local con1, con2
  89. con1 = main.InputBegan:Connect(function(input)
  90.     pressing = true
  91.     local lastPosition
  92.     local dis = UDim2.new(0, mouse.X, 0, mouse.Y) - main.Position
  93.     local loop
  94.     if input.UserInputType == mouseButton1 or input.UserInputType == Touch then
  95.         loop = game:GetService("RunService").RenderStepped:Connect(function()
  96.             if pressing == false then loop:Disconnect() return end
  97.             local pos = UDim2.new(0, mouse.X, 0, mouse.Y) - dis
  98.             if pos == lastPosition then return else lastPosition = pos end
  99.             if tweenEffect then
  100.                 main:TweenPosition(pos, "Out", "Sine", 0.1, true)
  101.             else
  102.                 main.Position = pos
  103.             end
  104.         end)
  105.     end
  106. end)
  107. con2 = game:GetService("UserInputService").InputEnded:Connect(function(input)
  108.     if inputMouse(input) then
  109.         pressing = false
  110.     end
  111. end)
  112.  
  113. local Boards = workspace.Interactions.Whiteboard
  114. local WhitelistBoards = {}
  115.  
  116. for i, v in pairs(Boards:GetChildren()) do
  117.     table.insert(WhitelistBoards, v:FindFirstChild("Board"))
  118. end
  119.  
  120. local function getTarget()
  121.     local unitRay = mouse.UnitRay
  122.     local castParams = RaycastParams.new()
  123.     castParams.FilterDescendantsInstances = WhitelistBoards
  124.     castParams.FilterType = Enum.RaycastFilterType.Whitelist
  125.  
  126.     local result = workspace:Raycast(unitRay.Origin, unitRay.Direction * 400, castParams)
  127.     return result and result.Instance
  128. end
  129.  
  130. local selection = Instance.new("SelectionBox")
  131. local selected = nil
  132. local infoConn
  133.  
  134. local inputConn; inputConn = uis.InputBegan:Connect(function(input)
  135.     if not inputMouse(input) then return end
  136.  
  137.     local target = getTarget()
  138.     if target and selected ~= target then
  139.         local surfacegui = target:FindFirstChildOfClass("SurfaceGui")
  140.         if surfacegui then
  141.             selected = target
  142.             print("Pointing to "..target:GetFullName())
  143.             selection.Parent = target.Parent
  144.  
  145.             local itext = surfacegui.Frame.Content
  146.             if infoConn then
  147.                 infoConn:Disconnect()
  148.             end
  149.             print(itext.Font)
  150.             local text = itext.Text
  151.             infoConn = itext:GetPropertyChangedSignal("ContentText"):Connect(function()
  152.                 text = text.."\n---------------------------------------\n"..itext.ContentText
  153.                 tb.Text = text
  154.             end)
  155.             tb.Text = text
  156.         end
  157.     end
  158. end)
  159.  
  160. -- Textbox changed
  161. local TextService = game:GetService("TextService")
  162. local textConn = tb:GetPropertyChangedSignal("ContentText"):Connect(function()
  163.     -- scroll.CanvasSize = UDim2.new(0, 0, 0, #string.split(tb.ContentText, "\n") * tb.TextSize)
  164.     local sizeY = TextService:GetTextSize(tb.Text, tb.TextSize, tb.Font, Vector2.new(tb.AbsoluteSize.X, 999999999)).Y
  165.     scroll.CanvasSize = UDim2.new(0, 0, 0, sizeY)
  166.     print(sizeY)
  167. end)
  168.  
  169. -- Minimize event
  170. local debounce = true
  171. local origSize = main.Size
  172. local minConn = minimize.MouseButton1Down:Connect(function()
  173.     if debounce then
  174.         debounce = false
  175.         minimize.Text = "+"
  176.         scroll.Visible = false
  177.         main.Size = UDim2.new(0, origSize.X.Offset, 0, 25)
  178.     else
  179.         debounce = true
  180.         minimize.Text = "-"
  181.         scroll.Visible = true
  182.         main.Size = origSize
  183.     end
  184. end)
  185.  
  186. -- Close window event
  187. button.MouseButton1Down:Connect(function()
  188.     sg:Destroy()
  189.     selection:Destroy()
  190.     con1:Disconnect()
  191.     con2:Disconnect()
  192.     inputConn:Disconnect()
  193.     textConn:Disconnect()
  194.     infoConn:Disconnect()
  195.     minConn:Disconnect()
  196. end)
Add Comment
Please, Sign In to add comment