Typewriter GUI Module

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 :slight_smile: (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 :smiley: .

Anyway thanks for checking the module out!

~ Gameknight

6 Likes

Do you have some example videos?

1 Like

I could make one if that would help!

Edit: Just uploaded the videos! If they aren’t informative enough just tell :smiley:

1 Like

Nice! I don’t really see this helping me but I am sure it can help people who are new to programming/who don’t know how to!

1 Like

This is very cool, i can see this help new programmers in terms of making a intro. Though, I think I would change the sound-effect, other than that amazing!

1 Like

Yep you can change the audio to anything you would like! When using the library use the SoundId option in the extraArgs table!

-- Example
Args = {
    ["SoundId"] = "rbxassetid://#########" --Insert any music ID in ###s
}

TypewriterLibary:TypeWrite(Label, Text, 3, Args) -- Add in extra arguments :)

I just have the default sound effect to be sans because I thought it would be funny lol :sweat_smile:

Edit: I just changed the default to a more realistic type :slight_smile: so yea

1 Like

Yeah, I knew you could change it but still super cool!

1 Like