How could I improve my Intro Script?

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

You’re a really smart guy. I wouldn’t doubt if you told me you’ve learned multiple other programming languages. You’re fast, efficient and you explain very well, crazy :+1:

3 Likes

Do note that:
task.desynchronize() and task.synchronize() can only run under scripts that are a descendant of an Actor. Else, the script would error.

1 Like

Thread is when you can pass through the script or do not stop other scripts even if there is a while loop for example, am I correct?

1 Like

That is really good, thank you!

1 Like

Why is the sound script not working?

for _,v in pairs(script.Parent:GetDescendants()) do
	if v.ClassName == "TextButton" then
		v:GetPropertyChangedSignal("MaxVisibleGraphemes"):Connect(function()
			script.Text:Play()
		end)
	end
end
1 Like

Imagine an actual thread :thread:. If we were to split it into two using task.desynchronize or coroutine.create, we will have… two threads! Okay, that was stupid but you get it.

These threads have their own code and work alongside each other.
If we had one thread running two loops, the first one would run but not the second one. However, if we had one loop on both threads, both loops would run.

while true do
--do something
end --will run

while true do
--do something else
end --will not run

--____________________--
------First Thread------
while true do
--do something
end --will run

-----Second Thread------
while true do
--do something else
end --will also run
4 Likes

I got it!! Also that was a good example not gonna lie XD. So threads makes you able to run multiple tasks at the same time?

2 Likes

That is correct!

Both coroutines and the task library work with threads well.

3 Likes

Thank you guys! You are helping me a lot! I am getting even more knowledges for yall :>. I will learn that, I will learn everything from Lua! Thank you for giving me the start.

3 Likes

Glad we could help you! Remember that you can still have help from others, you don’t need to learn everything yourself.

2 Likes

Thank you :> I will count with you and @Youf_Dev in case I need. If you want, of course XD

Talking about that, how long have you been working with Lua?

2 Likes