How could I improve my Intro Script?

Dude you just saved me a lot with that! Can you show me an example on how it can be done on my script?

1 Like

It is not necessary to fill in every parameter, just the first two are fine here.

2 Likes
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

1 Like

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.

3 Likes

Ohh!! I got it! :D, thank you :>

1 Like

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??

1 Like

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:
Capture d’écran 2023-08-09 à 04.38.45

More information about coroutine: coroutine | Documentation - Roblox Creator Hub

2 Likes

Wow! This is Kinda new to me, if it is not a nuisance could you please explain what you’ve made? Thank you!!

1 Like

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.

4 Likes

Kinda of got it! Is it similar to spawn() function?

1 Like

yes but when using the spawn() function, you can’t put arguments.

1 Like

Interesting! Thank you for knowing that! :smiley:

1 Like

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

2 Likes

It is hard to me but I can learn that! Parallel Luau and corountine!

1 Like

You’re welcome! If you have any more question you can ask me and probably @remcodesremcodes too. Anyway, good luck!

2 Likes

Actually, you can.

function SendToOutputForever(text: string)
while true do
print(text)
end
end

task.spawn(SendToOutputForever, "Hellooooooooooo")
--^^^
--never do this please
1 Like

i think coroutines are just slightly faster than task.spawn. Correct me if i’m wrong tho.

1 Like

I need to learn about Task too

1 Like

Agreed! Here is some more information about task if you want :wink: task | Documentation - Roblox Creator Hub

1 Like

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.

4 Likes