Sectly_Playz

Roblox:TypeWriter.Lua

Jan 3rd, 2022 (edited)
922
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.11 KB | None | 0 0
  1. -- // Made By: 27st3, Discord: Sectly_playz#1404
  2. -- // Makes A Cool TypeWriter Screen Text Effect With Rich Text Support! | (Roblox:TypeWriter.Lua)
  3.  
  4. --[[ -- // How To Use:
  5.  
  6. -- // Main:
  7.  
  8. Call Function: | Text Input: | Wait Time In Seconds:
  9.  
  10. Write("Your Text Here!", 5)
  11.  
  12. -- // Rich Text:
  13.  
  14. Bold:
  15.  
  16. Write("Your <b>Text</b> Here!", 5)
  17.  
  18. Underline:
  19.  
  20. Write("Your <u>Text</u> Here!", 5)
  21.  
  22. Italic:
  23.  
  24. Write("Your <i>Text</i> Here!", 5)
  25.  
  26. --]]
  27.  
  28. repeat wait() until game.Players.LocalPlayer.PlayerGui
  29.  
  30. local RunService = game:GetService("RunService")
  31. local PlayerGui = game.Players.LocalPlayer.PlayerGui
  32.  
  33. local TypeWriter = Instance.new("ScreenGui")
  34. local Container = Instance.new("Frame")
  35. local ListLayout = Instance.new("UIListLayout")
  36. local Padding = Instance.new("UIPadding")
  37.  
  38. TypeWriter.Name = "TypeWriter"
  39. TypeWriter.Parent = script
  40. TypeWriter.ResetOnSpawn = false
  41.  
  42. Container.Name = "Container"
  43. Container.Parent = TypeWriter
  44. Container.AnchorPoint = Vector2.new(0.5, 0.5)
  45. Container.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  46. Container.BackgroundTransparency = 1.000
  47. Container.BorderColor3 = Color3.fromRGB(0, 0, 0)
  48. Container.BorderSizePixel = 0
  49. Container.Position = UDim2.new(0.5, 0, 0.5, 0)
  50. Container.Size = UDim2.new(1, 0, 1, 0)
  51.  
  52. ListLayout.Name = "ListLayout"
  53. ListLayout.Parent = Container
  54. ListLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
  55. ListLayout.SortOrder = Enum.SortOrder.LayoutOrder
  56. ListLayout.VerticalAlignment = Enum.VerticalAlignment.Bottom
  57. ListLayout.Padding = UDim.new(0, 5)
  58.  
  59. Padding.Name = "Padding"
  60. Padding.Parent = Container
  61. Padding.PaddingBottom = UDim.new(0.25, 0)
  62. Padding.PaddingLeft = UDim.new(0.25, 0)
  63. Padding.PaddingRight = UDim.new(0.25, 0)
  64. Padding.PaddingTop = UDim.new(0.25, 0)
  65.  
  66. function Write(Text, Wait)
  67.     coroutine.wrap(function()
  68.         local Screen = PlayerGui:FindFirstChild("TypeWriter")
  69.  
  70.         if not Screen then
  71.             Screen = TypeWriter
  72.             Screen.Parent = PlayerGui
  73.         end
  74.  
  75.         local Message = Instance.new("TextLabel")
  76.  
  77.         Message.Name = "Message"
  78.         Message.Parent = script
  79.         Message.AnchorPoint = Vector2.new(0.5, 0.5)
  80.         Message.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  81.         Message.BackgroundTransparency = 1.000
  82.         Message.BorderColor3 = Color3.fromRGB(0, 0, 0)
  83.         Message.BorderSizePixel = 0
  84.         Message.Position = UDim2.new(0.5, 0, 0.5, 0)
  85.         Message.Size = UDim2.new(1, 0, 0, 20)
  86.         Message.Font = Enum.Font.Gotham
  87.         Message.RichText = true
  88.         Message.Text = ""
  89.         Message.TextColor3 = Color3.fromRGB(255, 255, 255)
  90.         Message.TextSize = 20.000
  91.         Message.TextStrokeTransparency = 0.500     
  92.  
  93.         Message.Parent = Screen.Container
  94.         Message.Text = Text
  95.         Message.Size = UDim2.new(1,0,0,Message.TextBounds.Y)
  96.  
  97.         local Index = 0
  98.         local DisplayText = Text
  99.         DisplayText = DisplayText:gsub("<br%s*/>", "\n")
  100.         DisplayText = DisplayText:gsub("<[^<>]->", "")
  101.  
  102.         for _ in utf8.graphemes(DisplayText) do
  103.             Index = Index + 1
  104.             Message.MaxVisibleGraphemes = Index
  105.             wait(0.005)
  106.         end
  107.         wait(Wait)
  108.         for _ in utf8.graphemes(DisplayText) do
  109.             Index = Index - 1
  110.             Message.MaxVisibleGraphemes = Index
  111.             wait(0.005)
  112.         end
  113.         Message:Destroy()
  114.     end)()
  115. end
Add Comment
Please, Sign In to add comment