ModuleScript:
local TweenService = game:GetService("TweenService")
local TextService = game:GetService("TextService")
local module = {}
local calculNumberOfLetters
local protectionOn = false
module.colors = {
['warm'] = {
['red'] = "<font color='rgb(255, 0, 0)'>", -- #ff0000
['orange'] = "<font color='rgb(255, 102, 0)'>", -- #ff6600
['yellow'] = "<font color='rgb(251, 255, 0)'>", -- #fbff00
['green'] = "<font color='rgb(47, 255, 0)'>", -- #2fff00
['light_blue'] = "<font color='rgb(0, 255, 234)'>", -- #00ffea
['dark_blue'] = "<font color='rgb(0, 17, 255)'>", -- #0011ff
['purple'] = "<font color='rgb(149, 0, 255)'>", -- #9500ff
['magenta'] = "<font color='rgb(200, 1, 255)'>", -- #c801ff
['pink'] = "<font color='rgb(247, 0, 255)'>", -- #f700ff
},
['cold'] = {
['red'] = "<font color='rgb(255, 75, 75)'>", -- #ff4b4b
['orange'] = "<font color='rgb(255, 142, 76)'>", -- #ff8e4c
['yellow'] = "<font color='rgb(253, 255, 129)'>", -- #fdff81
['green'] = "<font color='rgb(133, 255, 143)'>", -- #85ff8f
['light_blue'] = "<font color='rgb(124, 238, 255)'>", -- #7ceeff
['dark_blue'] = "<font color='rgb(103, 138, 255)'>", -- #678aff
['purple'] = "<font color='rgb(161, 142, 255)'>", -- #a18eff
['magenta'] = "<font color='rgb(193, 139, 255)'>", -- #c18bff
['pink'] = "<font color='rgb(223, 143, 255)'>", -- #df8fff
}
}
function module.addText(text:string, linepath:Frame, Time:number)
if protectionOn == false then
protectionOn = true
for i=1, #text do
local clone = script.Label:Clone()
clone.Parent = linepath
clone.Text = string.sub(text, i, i)
clone.Name = tostring(i)
local calculLetterSize = TextService:GetTextSize(clone.Text, clone.TextSize, clone.Font, Vector2.new(clone.AbsoluteSize.X, clone.AbsoluteSize.Y))
TweenService:Create(clone, TweenInfo.new(Time / #text), {Size = UDim2.new(calculLetterSize.X / clone.Parent.AbsoluteSize.X + 0.017, 0, 1, 0)}):Play()
task.wait(Time / #text)
end
protectionOn = false
end
end
function module.removeText(linepath:Frame, Time:number)
if protectionOn == false then
protectionOn = true
calculNumberOfLetters = 0
for i, clone in pairs(linepath:GetDescendants()) do
if clone:IsA('TextLabel') then
calculNumberOfLetters += 1
end
end
for i, clone in pairs(linepath:GetDescendants()) do
if clone:IsA('TextLabel') then
TweenService:Create(clone, TweenInfo.new(Time / calculNumberOfLetters), {Size = UDim2.new(0, 0, 0, 0)}):Play()
task.wait(Time / calculNumberOfLetters)
clone:Destroy()
end
end
protectionOn = false
end
end
return module
LocalScript (second line is what I want to look like for the colors):
local module = require(game:GetService("ReplicatedStorage").ModuleScript)
module.addText(module.colors['cold']['red'] .. 'Salut!', script.Parent.Main.Containers.Line1, 1)
module.addText('Comment vas-tu?', script.Parent.Main.Containers.Line2, 1)
module.addText('Sais-tu que 2+2 font 4!', script.Parent.Main.Containers.Line3, 1)
task.wait(1)
module.removeText(script.Parent.Main.Containers.Line1, 2.5)
module.removeText(script.Parent.Main.Containers.Line2, 2.5)
module.removeText(script.Parent.Main.Containers.Line3, 2.5)
Hey! I have 1 question and 1 problem, first, how to getDescendantst() from end to start and not start too end? Also, on my script above, when the player can choose the color with the table colors, how can I make that it change the text color?