Advertisement
abs_0

Material TextBox (lua)

Jan 18th, 2018
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.65 KB | None | 0 0
  1. local parent = script.Parent
  2. local mouse = game.Players.LocalPlayer:GetMouse()
  3.  
  4. local xsize = parent.Size.X.Offset
  5. local ysize = parent.Size.Y.Offset
  6. parent.Visible = true
  7. parent.Active = true
  8. parent.Selectable = true
  9.  
  10. local Underline = Instance.new("Frame")
  11. local UnderlineBase = Instance.new("Frame")
  12.  
  13. Underline.Name = "Underline"
  14. Underline.Parent = parent
  15. Underline.BackgroundColor3 = parent.TextColor3
  16. Underline.BorderSizePixel = 0
  17. Underline.Position = UDim2.new(0, 0, 1, 0)
  18. Underline.Size = UDim2.new(0, 0, 0, 1)
  19.  
  20. UnderlineBase.Name = "UnderlineBase"
  21. UnderlineBase.Parent = parent
  22. UnderlineBase.BackgroundColor3 = parent.TextColor3
  23. UnderlineBase.BackgroundTransparency = 0.85
  24. UnderlineBase.BorderSizePixel = 0
  25. UnderlineBase.Position = UDim2.new(0, 0, 1, 0)
  26. UnderlineBase.Size = UDim2.new(0, xsize, 0, 1)
  27.  
  28. parent.Focused:connect(function()
  29.     if Underline.Size == UDim2.new(0, 0, 0, 1) then
  30.         local x = (mouse.X) - (parent.AbsolutePosition.X)
  31.         Underline.BackgroundTransparency = 0
  32.         Underline.Position = UDim2.new(0,x,1,0)
  33.         wait()
  34.         Underline:TweenSizeAndPosition(
  35.             UDim2.new(0, xsize, 0, 1),
  36.             UDim2.new(0, 0, 1, 0),
  37.             "Out",
  38.             "Quint",
  39.             0.2
  40.         )
  41.     end
  42. end)
  43.  
  44. parent.FocusLost:connect(function()
  45.     if parent.Text == "" then
  46.         parent.Text = "TextBox"
  47.     end
  48.    
  49.     local TweenService = game:GetService("TweenService")
  50.    
  51.     local Info = TweenInfo.new(
  52.         0.15,
  53.         Enum.EasingStyle.Linear,
  54.         Enum.EasingDirection.Out,
  55.         0,
  56.         false,
  57.         0
  58.     )
  59.     local Goals =
  60.     {
  61.         BackgroundTransparency = 1;
  62.     }
  63.    
  64.     local tween = TweenService:Create(Underline,Info,Goals)
  65.     tween:Play()
  66.    
  67.     wait(0.15)
  68.     Underline.Size = UDim2.new(0,0,0,1)
  69. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement