vlatkovski

Typing effect (ROBLOX)

Jan 16th, 2015
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. write = function(str, delay, times, output)
  2.     --print("Output's a "..tostring(type(output)))
  3.     local s1 = string.rep(str,times) --makes the "times" work
  4.     local s2 = "";
  5.     for i=1,#s1 do --for every letter in s1
  6.         s2 = s2..s1:sub(i,i);
  7.         if not string.find(s2:sub(i,i),"%s") then
  8.             wait(delay); --makes it so it doesn't delay on whitespace characters
  9.         end
  10.         if type(output) == "userdata" then --sadly, if it's directly a string it won't work
  11.             local cn = output.ClassName; --saves a lot of typing
  12.             if output:IsA"GuiObject" and cn~="Frame" and cn~="ScrollingFrame" then
  13.                 output["Text"] = s2;
  14.             end
  15.         elseif type(output) == "function" then
  16.             output(s2);
  17.         end
  18.         i=i+1; --proceeds to the next letter
  19.     end
  20. end
  21.  
  22. --Example
  23.  
  24. write("Typing effect, woohoo!", 0.05, 1, print)
  25. --The first arg. is the text, "0.05" is the delay between letters, "1" is how much times it's going to be written, "print" means it's going to be printed (You can set it so it sets a name of something, text from GuiObjects etc.)
Advertisement
Add Comment
Please, Sign In to add comment