Advertisement
Wubzer

Type Writer Effect

Aug 30th, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.17 KB | None | 0 0
  1. local Players = (game.Players);
  2. local Player = (Players.LocalPlayer);
  3. local Character = (Player.Character);
  4.  
  5.  
  6. function TypeWriter(DebrisTime, String, BaseObj)
  7.     --// Type Writer Effect
  8.     --// Created by: Wubzer
  9.     --// I found the "magic number" 0.58333 just through trial and error of finding the perfect dynamic factor.
  10.     --// Destroy Extra Type Writer
  11.     if (workspace:FindFirstChild(Player.Name .. "[TypeWriterText]")) then workspace[Player.Name .. "[TypeWriterText]"]:Destroy(); end;
  12.     --// Variables
  13.     local VectorUp = (CFrame.new(0, -3.5, 0));
  14.     local TypePart = (Instance.new("Part", workspace));
  15.     local TypeBill = (Instance.new("BillboardGui", TypePart));
  16.     local TypeText = (Instance.new("TextLabel", TypeBill));
  17.     local TypeWeld = (Instance.new("Weld", TypePart));
  18.     --// TypePart
  19.     TypePart.BrickColor = (BrickColor.new("Really black"));
  20.     TypePart.Transparency = (1);
  21.     TypePart.Name = (Player.Name .. "[TypeWriterText]");
  22.     TypePart.CFrame = (BaseObj.CFrame)
  23.     TypePart.Anchored = (false);
  24.     TypePart.CanCollide = (false);
  25.     TypePart.Size = (Vector3.new(1, 1, 1));
  26.     --// TypeBill
  27.     TypeBill.Name = ("TypeBill");
  28.     TypeBill.Size = UDim2.new(string.len(String) * 0.58333, 0, 0.86, 0);
  29.     --// TypeText
  30.     TypeText.BackgroundTransparency = (1);
  31.     TypeText.Name = ("TypeText");
  32.     TypeText.Size = (UDim2.new(1, 0, 1, 0));
  33.     TypeText.Font = (Enum.Font.Antique);
  34.     TypeText.Text = ("");
  35.     TypeText.TextColor3 = (Color3.new(0, 0, 0));
  36.     TypeText.TextScaled = (true);
  37.     TypeText.TextStrokeColor3 = (Color3.new(1, 0, 0));
  38.     TypeText.TextStrokeTransparency = (0);
  39.     --// TypeWeld
  40.     TypeWeld.Part0 = (BaseObj);
  41.     TypeWeld.Part1 = (TypePart);
  42.     TypeWeld.C0 = (BaseObj.CFrame:inverse());
  43.     TypeWeld.C1 = (BaseObj.CFrame:inverse() * VectorUp);
  44.     --// Debris
  45.     game.Debris:AddItem(TypePart, (DebrisTime + (string.len(String) * 0.05)));
  46.     --// Change Text
  47.     for i = 1, string.len(String) do
  48.         if (not workspace:FindFirstChild(Player.Name .. "[TypeWriterText]")) then break; end;
  49.         workspace:FindFirstChild(Player.Name .. "[TypeWriterText]").TypeBill.TypeText.Text = (string.sub(String, 1, i));
  50.         wait(0.05);
  51.     end;
  52. end;
  53.  
  54. Player.Chatted:Connect(function(Msg)
  55.     TypeWriter(7, Msg, Character.HumanoidRootPart);
  56. end);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement