Dude you just saved me a lot with that! Can you show me an example on how it can be done on my script?
It is not necessary to fill in every parameter, just the first two are fine here.
local TS = game:GetService("TweenService")
local textbox = script.Parent
local TP = TS:Create(textbox, TweenInfo.new(1.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.In, 0, false, 25.3), {Position = UDim2.new(0.5,0,0.195,0)})
local TP2 = TS:Create(textbox, TweenInfo.new(1, Enum.EasingStyle.Quad), {Position = UDim2.new(0.5,0,0.7,0)})
TP:Play()
TP.Completed:Once(function()
TP2:Play()
for i = 1, string.len(textbox.Text) do
textbox.MaxVisibleGraphemes = i
task.wait(0.05)
end
end)
Button 3 btw
Old:
local TS = game:GetService("TweenService")
local tween = TweenInfo.new(1.5,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out,0,false,25.3)
local textbox = script.Parent
local TP = TS:Create(textbox,tween,{Position = UDim2.new(0.5,0,0.195,0)})
TP:Play()
local TP2 = TS:Create(textbox,TweenInfo.new(0.999,Enum.EasingStyle.Quad,Enum.EasingDirection.In,0,false,0),{Position = UDim2.new(0.5,0,0.7,0)})
TP.Completed:Connect(function()
TP2:Play()
for i = 1, string.len(textbox.Text) do
textbox.MaxVisibleGraphemes = i
task.wait(0.05)
end
end)
New:
local TS = game:GetService("TweenService")
local textbox = script.Parent
local TP = TS:Create(textbox, TweenInfo.new(1.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.In, 0, false, 25.3), {Position = UDim2.new(0.5,0,0.195,0)})
local TP2 = TS:Create(textbox, TweenInfo.new(1, Enum.EasingStyle.Quad), {Position = UDim2.new(0.5,0,0.7,0)})
TP:Play()
TP.Completed:Once(function()
TP2:Play()
for i = 1, string.len(textbox.Text) do
textbox.MaxVisibleGraphemes = i
task.wait(0.05)
end
end)
You can tell which one is more optimised just by looking at them.
Ohh!! I got it! :D, thank you :>
How could I make those 3 scripts into just one script? I know I can do that but I am doing something important at the moment so I do not have much time to think… Sorry??
You can do all of that in just 1 script. Here is what I came up with. By the way, I noticed that the third textBox had 2 animations so make sure the variable textbox3
is the textbox with the extra animation.
script:
local TS = game:GetService("TweenService")
local textbox1 = script.Parent.TextBox1
local textbox2 = script.Parent.TextBox2
local textbox3 = script.Parent.TextBox3
local function tween(object, tweenTime, EasingStyle, EasingDirection, delayTime, PositionUdim2, timeAfterTween)
local tweenInfo = TweenInfo.new(tweenTime,EasingStyle,EasingDirection,0,false,delayTime)
local tween = TS:Create(object, tweenInfo, {Position = PositionUdim2})
local tween2 = TS:Create(object,TweenInfo.new(0.999,Enum.EasingStyle.Quad,Enum.EasingDirection.In,0,false,0),{Position = UDim2.new(0.5,0,0.7,0)})
tween:Play()
if object == textbox3 then
tween.Completed:Wait()
tween2:Play()
else
task.wait(timeAfterTween)
end
for i = 1, string.len(object.Text) do
object.MaxVisibleGraphemes = i
task.wait(0.05)
end
end
coroutine.wrap(tween)(textbox1, 5.4, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 8.4, UDim2.new(0.144,0,0.3,0), 8.8)
coroutine.wrap(tween)(textbox2, 5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 12.8, UDim2.new(0.856,0,0.3,0), 13.5)
coroutine.wrap(tween)(textbox3, 1.5,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out,25.3, UDim2.new(0.5,0,0.195,0), nil)
Explorer:
More information about coroutine: coroutine | Documentation - Roblox Creator Hub
Wow! This is Kinda new to me, if it is not a nuisance could you please explain what you’ve made? Thank you!!
He has connected a function to a coroutine
A coroutine links towards Parallel Luau which is kind of advanced in terms of scripting.
Although, essentially what it does is create a new thread for the function to run on. This way, the function can run without any disturbances.
Kinda of got it! Is it similar to spawn() function?
yes but when using the spawn() function, you can’t put arguments.
Interesting! Thank you for knowing that!
In a way, yes.
Though, coroutines are better in most cases as it allows you to control it at any time.
coroutine.resume()
coroutine.yield()
coroutine.create()
coroutine.wrap()
and so on
It is hard to me but I can learn that! Parallel Luau and corountine!
You’re welcome! If you have any more question you can ask me and probably @remcodesremcodes too. Anyway, good luck!
Actually, you can.
function SendToOutputForever(text: string)
while true do
print(text)
end
end
task.spawn(SendToOutputForever, "Hellooooooooooo")
--^^^
--never do this please
i think coroutines are just slightly faster than task.spawn. Correct me if i’m wrong tho.
I need to learn about Task too
Agreed! Here is some more information about task if you want task | Documentation - Roblox Creator Hub
The Task Library is a library of functions.
Every function in this library starts with task.
These functions include:
task.wait()
task.spawn()
task.defer()
task.desynchronize()
task.synchronize()
task.delay()
task.cancel()
The task library is designed to keep the game running smoothly and efficiently.
There is a system named Parallel where scripts can be split into main and side threads.
This allows different parts of your script to run things at the same time allowing for less work to be done on one thread.
This ensures that your game will load each frame faster than normal.