Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- write = function(str, delay, times, output)
- --print("Output's a "..tostring(type(output)))
- local s1 = string.rep(str,times) --makes the "times" work
- local s2 = "";
- for i=1,#s1 do --for every letter in s1
- s2 = s2..s1:sub(i,i);
- if not string.find(s2:sub(i,i),"%s") then
- wait(delay); --makes it so it doesn't delay on whitespace characters
- end
- if type(output) == "userdata" then --sadly, if it's directly a string it won't work
- local cn = output.ClassName; --saves a lot of typing
- if output:IsA"GuiObject" and cn~="Frame" and cn~="ScrollingFrame" then
- output["Text"] = s2;
- end
- elseif type(output) == "function" then
- output(s2);
- end
- i=i+1; --proceeds to the next letter
- end
- end
- --Example
- write("Typing effect, woohoo!", 0.05, 1, print)
- --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