Hi guys, i just woke up and made subtitles module
Getting Started
Module can handle only one player, so at first, put module into StarterCharacterScripts/StarterPlayerScripts
If you’re bold, you can learn some documentation and make your
subtitles cooler and easier to control. :
Documentation
Initial setup functions
.SetSubtitles()
This function sets your subtitles.
Parameters
Link
- Path to your subtitles. It can be anything that have “Text” property.
Example: Module.SetSubtitles(Player.PlayerGui.ScreenGui.TextLabel)
.SetBackground()
This function sets your background.
Parameters
Link
- Path to your background. It can be anything that have “BackgroundTransparency” property.
Example: Module.SetSubtitles(Player.PlayerGui.ScreenGui.Frame)
.SetFadingConfig()
This function sets your Fade config. It defines how transparent will be text and background when it’s visible. Also it have TweenInfo, so you can smoothly show your subtitles.
Parameters
Info
- Defines tween properties [Type - TweenInfo][Unnecessary]
TextTransparecy
- Defines text transparecy [Type - number][Unnecessary]
BackgroundTransparency
- Defines background transparecy [Type - number][Unnecessary]
Example: Module.SetFadingConfig(TweenInfo.new(2, Enum.EasingStyle.Sine), 0, 0.7)
Functions for work
:Write()
This function just print text and show to user
Parameters
Text
- It’s text. [Type - string][Necessary]
BaseColors
- table, containing color for text and background [Type - Color3][Unnecessary]
Duration
- delay before hiding subtitles [Type - number][Unnecessary]
UseFade
- defines will be appear and hide tweened or not [Type - boolean][Unnecessary]
Sound
- sound that will be played when subtitles appear [Type - Instance.Sound][Unnecessary]
Example:
Module:Write("Hi Mom", {Color3.fromRGB(255, 255, 255), Color3.fromRGB(0, 0, 0)}, 2, true, script.Sound)
:TypeWrite()
This function gradually prints your text
Parameters
Text
- It’s text. [Type - string][Necessary]
BaseColors
- table, containing color for text and background [Type - Color3][Unnecessary]
Duration
- delay before hiding subtitles [Type - number][Unnecessary]
UseFade
- Will Tween be used to show and hide subtitles
or not [Type - boolean][Unnecessary]
Sound
- sound that will be played on every character
appearance [Type - Instance.Sound][Unnecessary]
Interval
- delay befone next character will appear [Type - number][Unnecessary]
IntervalsConfig
- table containing defined interval on defined
character number [Type - number][Unnecessary]
AutomaticCapture
- Allows don’t waste time to make IntervalsConfig and make
it by script [Type - boolean][Unnecessary]
Example:
Module:TypeWrite("Hello_World", {Color3.fromRGB(255, 255, 255), Color3.fromRGB(0, 0, 0)}, 3, true, script.Sound, 0.05, {[10] = 0.7, [15] = 0.5, [27] = 1}, false)
.AddToQueue()
This function adds your functions into queue in defined order
Parameters
Type
- defines function you want to add. It can be “Write” or “TypeWrite” [Type - string][Necessary]
Params
- table with parameters for your selected function type [Type - table][Necessary]
Example:
Module.AddToQueue("Write", {"Hi Mom", {Color3.fromRGB(255, 255, 255), Color3.fromRGB(0, 0, 0)}, 1, true, nil})
:UseQueue()
This function runs functions in your queue
:Stop()
This function stops printing
Warnings
:Stop()
function need some time to stop code
Module may not work properly in languages except English, that’s not my and not Roblox’s fault.
If, however, you don’t want so much possibilities then you need to
do 1 (or maybe 2) simple things:
-
Set your subtitles - use
.SetSubtitles()
method to do this. Just put path to subtitles in parameters. -
[Optional] Set your background - use
.SetBackground()
. Background can be anything, that have BackgroundTransparency property
That’s all. Now you can print your text.
Simple print functions:
-
:Write()
- Just prints your text and shows it to user. First parameter is text -
:TypeWrite()
- Gradually prints text. First parameter is text
Example code:
--LocalScript in StarterCharacterScripts
local Player = game:GetService("Players").LocalPlayer
local Module = require(script.Parent.SubtitlesModule)
Module.SetSubtitles(Player.PlayerGui.ScreenGui.TextLabel)
Module.SetFadingConfig(TweenInfo.new(0.3, Enum.EasingStyle.Sine), 0, 0.7)
Module:TypeWrite("I love my mom", {Color3.fromRGB(255, 255, 255), Color3.fromRGB(0, 0, 0)}, 3, true, script["Switch 2 (SFX)"], 0.05, nil, false)
Here’s link btw
If you find grammar mistakes somewhere, please, let me know about it. I don’t want to be a fool.