You should check this out!
A # gets the length of something, so for example:
There are 5 models inside 1 model.
print(#TestModel:GetChildren()) -- 5
There are 25 parts together in the entire model
print(#TestModel:GetDescendants()) -- 25
Now as you have learnt about # let’s now step it up to the for loops!
What are for loops?
Well, for loops are really really helpful! If you want to make all the parts in a model Transparent to 1 at once, you might think. Variables for each part should do it! But that’s a long process. If you want to make it shorter use for loops.
You can go ahead loop through the entire model and check if the value is a BasePart or not. If it is then we will change its transparency to 1. How do you do this?
local model = script.Parent
for i, v in pairs(model:GetDescendants()) do -- i = index, v = value
if v:IsA("BasePart") then -- Checking if the v is a BasePart or not. If it is then
v.Transparency = 1
end
end
Now, your main question you asked. What is for i = 1, #table do
?
It’s a little little bit difficult than the other one, but hey, not too hard.
So, how does it work?
I’ll show an example with how you showed. So, you’re making a typetext. Now, this is how you do it.
local text = "This text is cool!"
for i - 1, #text do -- 1 is the starting number. So, 1 will be T from "This" in the text. And #text is the ending number. Instead of counting how many alphabets there are, just put a #
-- I'm not gonna explain the other stuff for now. You can check out other posts but hopefully this helped!
end