Ameno__GodOH

pastebinho

Oct 23rd, 2024 (edited)
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. local Library = {}
  2.  
  3. -- Função para criar um botão redondo com duas texturas
  4. function Library.NewButton(parent, buttonText, buttonInfo, outerTextureId, innerTextureId, innerSize, outerSize, position, buttonSize, callback)
  5. local button = Instance.new("TextButton")
  6. button.Size = buttonSize -- Tamanho do botão
  7. button.Position = position -- Posição do botão
  8. button.BackgroundTransparency = 1 -- Transparente para texturas
  9. button.Parent = parent
  10.  
  11. -- Criação da imagem externa (textura externa)
  12. local outerImage = Instance.new("ImageLabel")
  13. outerImage.Size = outerSize -- Tamanho da textura externa
  14. outerImage.Image = outerTextureId -- Textura externa definida aqui
  15. outerImage.BackgroundTransparency = 1
  16. outerImage.Parent = button
  17.  
  18. -- Criação da imagem interna (textura interna)
  19. local innerImage = Instance.new("ImageLabel")
  20. innerImage.Size = innerSize -- Tamanho da textura interna
  21. innerImage.Position = UDim2.new(0.5, -innerSize.X.Offset / 2, 0.5, -innerSize.Y.Offset / 2) -- Centraliza a textura interna
  22. innerImage.Image = innerTextureId -- Textura interna definida aqui
  23. innerImage.BackgroundTransparency = 1
  24. innerImage.Parent = button
  25.  
  26. -- Criação do TextLabel para o texto dentro do botão
  27. local innerLabel = Instance.new("TextLabel")
  28. innerLabel.Size = UDim2.new(0.8, 0, 0.8, 0)
  29. innerLabel.Position = UDim2.new(0.1, 0, 0.1, 0) -- Centraliza o TextLabel
  30. innerLabel.Text = buttonText
  31. innerLabel.BackgroundTransparency = 1
  32. innerLabel.TextColor3 = Color3.fromRGB(255, 255, 255) -- Cor do texto
  33. innerLabel.Parent = button
  34.  
  35. -- Tooltip ou info do botão
  36. button.MouseEnter:Connect(function()
  37. innerLabel.Text = buttonInfo -- Altera o texto ao passar o mouse
  38. end)
  39.  
  40. button.MouseLeave:Connect(function()
  41. innerLabel.Text = buttonText -- Retorna ao texto original
  42. end)
  43.  
  44. -- Função de callback ao clicar no botão
  45. button.MouseButton1Click:Connect(function()
  46. callback()
  47. end)
  48.  
  49. -- Estilo redondo
  50. button.ClipsDescendants = true
  51. button.BorderSizePixel = 0 -- Sem borda
  52. button.BackgroundColor3 = Color3.new(1, 1, 1) -- Cor de fundo (opcional)
  53. end
  54.  
  55. -- Função para criar um botão com TextLabel (apenas uma textura)
  56. function Library.NewTextButton(parent, buttonText, buttonInfo, textureId, size, position, callback, labelText)
  57. local button = Instance.new("TextButton")
  58. button.Size = size -- Tamanho do botão
  59. button.Position = position -- Posição do botão
  60. button.BackgroundTransparency = 1 -- Transparente para texturas
  61. button.Parent = parent
  62.  
  63. -- Criação da imagem (textura única)
  64. local textureImage = Instance.new("ImageLabel")
  65. textureImage.Size = UDim2.new(1, 0, 1, 0)
  66. textureImage.Image = textureId -- Textura definida aqui
  67. textureImage.BackgroundTransparency = 1
  68. textureImage.Parent = button
  69.  
  70. -- Criação do TextLabel para o texto dentro do botão
  71. local innerLabel = Instance.new("TextLabel")
  72. innerLabel.Size = UDim2.new(0.8, 0, 0.8, 0)
  73. innerLabel.Position = UDim2.new(0.1, 0, 0.1, 0) -- Centraliza o TextLabel
  74. innerLabel.Text = labelText or buttonText -- Texto padrão se labelText não for fornecido
  75. innerLabel.BackgroundTransparency = 1
  76. innerLabel.TextColor3 = Color3.fromRGB(255, 255, 255) -- Cor do texto
  77. innerLabel.Parent = button
  78.  
  79. -- Tooltip ou info do botão
  80. button.MouseEnter:Connect(function()
  81. innerLabel.Text = buttonInfo -- Altera o texto ao passar o mouse
  82. end)
  83.  
  84. button.MouseLeave:Connect(function()
  85. innerLabel.Text = labelText or buttonText -- Retorna ao texto original
  86. end)
  87.  
  88. -- Função de callback ao clicar no botão
  89. button.MouseButton1Click:Connect(function()
  90. callback()
  91. end)
  92.  
  93. -- Estilo redondo
  94. button.ClipsDescendants = true
  95. button.BorderSizePixel = 0 -- Sem borda
  96. button.BackgroundColor3 = Color3.new(1, 1, 1) -- Cor de fundo (opcional)
  97. end
  98.  
  99. return Library
Advertisement
Add Comment
Please, Sign In to add comment