Advertisement
SigmaBoy456

Roblox Example GUI ep1

Sep 22nd, 2024
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. local GUI = Instance.new("ScreenGui", game.CoreGui)
  2. GUI.Name = "My GUI"
  3. -- Frame
  4. local mainFrame = Instance.new("Frame", GUI)
  5. mainFrame.Size = UDim2.new(0, 100, 0, 100)
  6. mainFrame.Position = UDim2.new(0, 300, 0, 50)
  7. mainFrame.BackgroundColor3 = Color3.new(1, 1, 1)
  8. mainFrame.Name = "My Frame"
  9. mainFrame.Active = true
  10. mainFrame.Draggable = true
  11. -- Title
  12. local title = Instance.new("TextLabel", mainFrame)
  13. title.Name = "My title"
  14. title.Text = "This is My GUI"
  15. title.Size = UDim2.new(0, 100, 0, 20)
  16. title.BackgroundColor3 = Color3.new(1, 1, 1)
  17. title.TextScaled = true
  18. title.Position = UDim2.new(0, 0, 0, 0)
  19. -- button
  20. local button = Instance.new("TextButton", mainFrame)
  21. button.Size = UDim2.new(0, 100, 0, 20)
  22. button.Position = UDim2.new(0, 0, 0, 20)
  23. button.Name = "My Button"
  24. button.Text = "Click me"
  25. button.TextScaled = true
  26. button.BackgroundColor3 = Color3.new(1, 1, 1)
  27. -- Event when clicked
  28. button.MouseButton1Click:Connect(function()
  29. print("hello world")
  30. end)
  31.  
  32. -- Open / Close Button
  33. local Close = Instance.new("TextButton", GUI)
  34. Close.Size = UDim2.new(0, 40, 0, 40)
  35. Close.Position = UDim2.new(0, 0, 0, 150)
  36. Close.Name = "Close and Open"
  37. Close.BackgroundColor3 = Color3.new(1, 1, 1)
  38. Close.Text = "Open/Close"
  39. Close.TextScaled = true
  40. -- Event Open and close
  41. Close.MouseButton1Click:Connect(function()
  42. if mainFrame.Visible then
  43. mainFrame.Visible = false
  44. elseif not mainFrame.Visible then
  45. mainFrame.Visible = true
  46. end
  47. end)
  48.  
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement