Advertisement
abs_0

Material buttons and textboxes

Jan 19th, 2018
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.77 KB | None | 0 0
  1. function materializeb(button, color, transp, speed)
  2.     local parent = button
  3.     local circlecolor = color or parent.TextColor3
  4.     local ripplespeed = speed or 1
  5.     local transparency = transp or 0.8
  6.  
  7.     button = button or script.Parent
  8.     color = color or parent.TextColor3
  9.     speed = speed or 1
  10.     transp = transp or 0.8
  11.  
  12.     local mouse = game.Players.LocalPlayer:GetMouse()
  13.     local diagonal = math.sqrt((parent.Size.X.Offset) ^ 2 + (parent.Size.Y.Offset) ^ 2)
  14.     parent.ClipsDescendants = true
  15.     parent.Active = true
  16.     parent.Selectable = true
  17.     parent.Visible = true
  18.     parent.AutoButtonColor = false
  19.  
  20.     -- Object and Properties
  21.     local circle = Instance.new("ImageLabel")
  22.     circle.Name = "CircleLabel"
  23.     circle.Parent = parent
  24.     circle.AnchorPoint = Vector2.new(0.5, 0.5)
  25.     circle.BackgroundColor3 = Color3.new(1,1,1)
  26.     circle.BackgroundTransparency = 1
  27.     circle.BorderSizePixel = 0
  28.     circle.Position = UDim2.new(0,0,0,0)
  29.     circle.Size = UDim2.new(0,50,0,50)
  30.     circle.Visible = false
  31.     circle.Image = "rbxassetid://200182847"
  32.     circle.ImageColor3 = circlecolor
  33.  
  34.    
  35.  
  36.     parent.MouseButton1Down:connect(function()
  37.         --Script
  38.         local x = (mouse.X) - (parent.AbsolutePosition.X)
  39.         local y = (mouse.Y) - (parent.AbsolutePosition.Y)
  40.         circle.Position = UDim2.new(0,x,0,y)
  41.         circle.Size = UDim2.new(0,5,0,5) -- edit this to make it bigger before animation
  42.         circle.ImageTransparency = transparency
  43.         circle.Visible = true
  44.        
  45.         wait()
  46.        
  47.         circle:TweenSize(
  48.             UDim2.new(0, diagonal * 2, 0, diagonal * 2),
  49.             "Out",
  50.             "Quad",
  51.             ripplespeed
  52.         )
  53.     end)
  54.  
  55.     parent.MouseButton1Up:connect(function()
  56.         wait(0.65)
  57.         local TweenService = game:GetService("TweenService")
  58.         local circ = circle
  59.        
  60.         local Info = TweenInfo.new(
  61.             0.2, -- changes length of fading circle
  62.             Enum.EasingStyle.Linear,
  63.             Enum.EasingDirection.Out,
  64.             0,
  65.             false,
  66.             0
  67.         )
  68.         local Goals =
  69.         {
  70.             ImageTransparency = 1;
  71.         }
  72.        
  73.         local tween = TweenService:Create(circ,Info,Goals)
  74.         tween:Play()
  75.     end)
  76. end
  77.  
  78. function materializet(textbox, color, revertedtext)
  79.     local parent = textbox
  80.     local mouse = game.Players.LocalPlayer:GetMouse()
  81.     local underlinecolor = color or parent.TextColor3
  82.     local ptext = revertedtext or "TextBox"
  83.  
  84.     local xsize = parent.Size.X.Offset
  85.     local ysize = parent.Size.Y.Offset
  86.     parent.Visible = true
  87.     parent.Active = true
  88.     parent.Selectable = true
  89.  
  90.     local Underline = Instance.new("Frame")
  91.     local UnderlineBase = Instance.new("Frame")
  92.  
  93.     Underline.Name = "Underline"
  94.     Underline.Parent = parent
  95.     Underline.BackgroundColor3 = underlinecolor
  96.     Underline.BorderSizePixel = 0
  97.     Underline.Position = UDim2.new(0, 0, 1, 0)
  98.     Underline.Size = UDim2.new(0, 0, 0, 2)
  99.  
  100.     UnderlineBase.Name = "UnderlineBase"
  101.     UnderlineBase.Parent = parent
  102.     UnderlineBase.BackgroundColor3 = underlinecolor
  103.     UnderlineBase.BackgroundTransparency = 0.85
  104.     UnderlineBase.BorderSizePixel = 0
  105.     UnderlineBase.Position = UDim2.new(0, 0, 1, 0)
  106.     UnderlineBase.Size = UDim2.new(0, xsize, 0, 1)
  107.  
  108.     parent.Focused:connect(function()
  109.         local x = (mouse.X) - (parent.AbsolutePosition.X)
  110.         Underline.BackgroundTransparency = 0
  111.         Underline.Position = UDim2.new(0,x,1,0)
  112.         wait()
  113.         Underline:TweenSizeAndPosition(
  114.             UDim2.new(0, xsize, 0, 1),
  115.             UDim2.new(0, 0, 1, 0),
  116.             "Out",
  117.             "Quint",
  118.             0.2
  119.         )
  120.     end)
  121.  
  122.     parent.FocusLost:connect(function()
  123.         if parent.Text == "" then
  124.             parent.Text = ptext
  125.         end
  126.        
  127.         local TweenService = game:GetService("TweenService")
  128.        
  129.         local Info = TweenInfo.new(
  130.             0.15,
  131.             Enum.EasingStyle.Linear,
  132.             Enum.EasingDirection.Out,
  133.             0,
  134.             false,
  135.             0
  136.         )
  137.         local Goals =
  138.         {
  139.             BackgroundTransparency = 1;
  140.         }
  141.        
  142.         local tween = TweenService:Create(Underline,Info,Goals)
  143.         tween:Play()
  144.        
  145.         wait(0.15)
  146.         Underline.Size = UDim2.new(0,0,0,1)
  147.     end)
  148. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement