Typewriter GUI Module
I decided to create a type-writer module to work on my documentation skills. Its completely open source so feel free to use any of the code written (just maybe give credit if possible :> ~thx)
Module Info:
This module can be used to create a typewriter like effect for all text guis. It is also capable of creating scripts to run at certain times and sound effects. The usage is fairly simplistic with most of the setup being done for you already. Some example usage of each of the functions is below the API section of this post.
Created by: Gameknight9992005
API:
function TypeWrite(GuiObject, Text, Time, ExtraArgs)
Creates a typewriting effect on the text of GuiObject
GuiObject: Instance
The GuiObject the text will be changed in
Text: string
The text that will be typed into the GuiObject
Time: number
The amount of time (in seconds) the typewriter affect will take up
ExtraArgs: dictionary
Extra optional arguments for the typewriting affect
ExtraArgs Table Keys
1: PunctWaitOn [bool] --Will wait on punctuation marks
2: PunctWaitTime [number] --Wait time on punctuation marks
3: SpaceWaitOn [bool] --Will wait on spaces
4: SpaceWaitTime [number] --Wait time on spaces
5: SoundId [string] --String of SoundId (Ex: "rbxassetid://5861332769")
returns void
.
function MuteSFX()
Mutes Typewriting Sound Effect (Typewriting sfx muted by default)
returns void
.
function UnmuteSFX()
Unmutes Typewriting Sound Effect (Typewriting sfx muted by default)
returns void
.
function CreateScript(scriptName)
Creates a new script with the name passed in scriptName
scriptName: string
The name the script will be called
returns void
.
function DestroyScript(scriptName)
Destroys script with the name passed in scriptName
scriptName: string
The name of the script will be destroyed
returns void
.
function DestroyAllScripts()
Destroys all scripts that have been created
returns void
.
function GetAllScripts()
Returns a dictionary with all created scripts inside
returns dictionary
.
function AddMessage(scriptName, msg, time, waitTimeAfter, args)
Adds message with all arguments to script called scriptName
scriptName: string
Name of already created script
msg: string
The text that will be typed into a GuiObject
time: number
The amount of time (in seconds) the typewriter affect will take up
waitTimeAfter: number
The amount of time (in seconds) waited before going to the next message
args: dictionary
Extra optional arguments for the typewriting affect
returns void
.
function RemoveMessage(scriptName, messageNum)
Removes Message from script called scriptName (messageNum starts at 1)
scriptName: string
Name of already created script
messageNum: number
The message number of the script to be removed
returns void
.
function PlayScript(GuiObject, scriptName)
Runs a created script named scriptName on GuiObject
GuiObject: Instance
The GuiObject that the typewriting affect will be applied to
scriptName: string
Name of already created script
returns void
.
Usage:
Its hard to understand an API without and example so here are two example scripts!
Typewriting Example:
local TypewriterLibrary = require(script.TypeWriterLib) --Replace inside require with module location
local Label = script.Parent --TextLabel or GUI that has Text Property
local Text = "Hello World :) This module helps create typewriting effects!!!"
local Args = { --Extra Arguments for typewriter affect
["PunctWaitOn"] = false,
["SpaceWaitOn"] = true,
["SpaceWaitTime"] = 0.02,
["SoundId"] = "rbxassetid://5861332769"
}
TypewriterLibrary:UnmuteSFX() --Unmutes Sound Effects
wait(5) -- Wait to spawn in
TypewriterLibrary:TypeWrite(Label, Text, 3, Args) -- Creates Typewriting affect!
Scripts Example:
local TypewriterLibrary = require(script.TypeWriterLib) --Replace inside require with module location
local Label = script.Parent --TextLabel or GUI that has Text Property
local Args = { --Extra Arguments for typewriter affect
["PunctWaitOn"] = true,
["SpaceWaitOn"] = true,
["SpaceWaitTime"] = 0.05
}
TypewriterLibrary:UnmuteSFX() --Unmute Sound Effects
TypewriterLibrary:CreateScript("JohnDoeScript") --New Script
TypewriterLibrary:AddMessage("JohnDoeScript", "Hello world!", 1, 1, Args) --Add message to script
TypewriterLibrary:AddMessage("JohnDoeScript", "This script sure is helpful :) I sure hope it helps!", 2, 1, Args)
TypewriterLibrary:AddMessage("JohnDoeScript", "oops! This message is a mistake!", 1, 3)
TypewriterLibrary:RemoveMessage("JohnDoeScript", 3) -- Removes 3rd message
wait(5) -- Wait to spawn in
TypewriterLibrary:PlayScript(Label, "JohnDoeScript")
print(TypewriterLibrary:GetAllScripts())
TypewriterLibrary:DestroyAllScripts() --Destroys/resets all scripts
Video Examples:
Sources:
https://www.roblox.com/library/6541699442/Type-Writer-Library
Final Thoughts:
I may update this library but don’t count on weekly updates XD. This Library was just more or less a chance to improve my documentation skills as there are hundreds of other typewriting libraries. Feel free to give any feedback on what documentation or cleaner code things I could improve on .
Anyway thanks for checking the module out!
~ Gameknight