Advertisement
DrawingJhon

Cool Chat

Jul 16th, 2022
1,038
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.01 KB | None | 0 0
  1. local sg = Instance.new("ScreenGui", game.CoreGui)
  2. sg.Name = "CoolChat"
  3. local main = Instance.new("Frame", sg)
  4. main.Name = "Main"
  5. main.AnchorPoint = Vector2.new(0, 1)
  6. main.Position = UDim2.new(0, 40, 1, -40)
  7. main.Size = UDim2.new(0, 400, 0, 200)
  8. main.BorderSizePixel = 0
  9. main.BackgroundColor3 = Color3.fromRGB(15, 15, 15)
  10. main.BackgroundTransparency = 0.3
  11. local top = Instance.new("Frame", main)
  12. top.Name = "Top"
  13. top.Size = UDim2.new(1, 0, 0, 25)
  14. top.BorderSizePixel = 0
  15. top.BackgroundColor3 = Color3.new()
  16. top.BackgroundTransparency = 1
  17. local close = Instance.new("TextButton", top)
  18. close.Name = "Close"
  19. close.AnchorPoint = Vector2.new(1, 0)
  20. close.Position = UDim2.new(1, -5, 0, 0)
  21. close.Size = UDim2.new(0, 30, 0, 20)
  22. close.BackgroundColor3 = Color3.new(1, 0, 0)
  23. close.BackgroundTransparency = 0.3
  24. close.Text = "X"
  25. close.TextColor3 = Color3.new(1, 1, 1)
  26. close.BorderSizePixel = 0
  27. local control = Instance.new("Frame", main)
  28. control.Name = "Control"
  29. control.AnchorPoint = Vector2.new(0.5, 0)
  30. control.Position = UDim2.new(0.5, 0, 0, 25)
  31. control.Size = UDim2.new(1, -10, 1, -30)
  32. control.BorderSizePixel = 0
  33. control.BackgroundColor3 = Color3.fromRGB(15, 15, 15)
  34.  
  35. local uis = game:GetService("UserInputService")
  36. local replicated = game:GetService("ReplicatedStorage")
  37.  
  38. -- Events
  39. close.MouseButton1Click:Connect(function()
  40.     sg:Destroy()
  41. end)
  42.  
  43. -- Draggable
  44. local pressing = false
  45. local pressOffset = UDim2.new()
  46.  
  47. main.InputBegan:Connect(function(input)
  48.     if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  49.     pressOffset = UDim2.new(0, input.Position.X, 0, input.Position.Y) - main.Position
  50.     pressing = true
  51. end)
  52.  
  53. uis.InputEnded:Connect(function(input)
  54.     if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  55.     pressing = false
  56. end)
  57.  
  58. uis.InputChanged:Connect(function(input)
  59.     if input.UserInputType ~= Enum.UserInputType.MouseMovement then return end
  60.     if pressing then
  61.         main.Position = UDim2.new(0, input.Position.X, 0, input.Position.Y) - pressOffset
  62.     end
  63. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement