Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I wanted to understand the use of * For * and * # * before some variable?

Asked by
lytew 99
4 years ago

I wanted to understand the use of * For * and * # * before some variable,for example:

local teleporte = script.Parent

function onClicked()

local p = game.Players:GetChildren()
for i = 1, #p do
p[i].Character:MoveTo(Vector3.new(-55.831, 11.008, 183.894))
teleporte.ClickDetector.MaxActivationDistance = 0


end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

I wanted to understand how to use and the use of them

0
for is a keyword used to start a for iterator loop and # returns the length of either a given table or given string DeceptiveCaster 3761 — 4y

2 answers

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

[#] - Operator - This returns either the length of an string or the length of a table.

local Table = {'hi', 'there', 'world'}
print(#Table)
-- Output : 3

[*] - Operator - This is the multiplication operator.

local NumberVar = 10
print(NumberVar * 5)
-- Output : 50

[For] - Syntax - This is used in For Loops in lua to iterate through tables, string functions that return a table (ex: string.split), numbers, etc.

for Iteration = 1, 10 do 
    print(Iteration)  -- prints from 1 to 10
end

Hope this has cleared the questions of yours, if you have any more feel free to ask me.

Ad
Log in to vote
1
Answered by 4 years ago

If you put # right before a table it will represent a number of how much objects are on that table, * is for multiplication. Example:

print(5 * 2)

That will print 10.

Answer this question