1 | if Hit.Parent.Team.Value = = TeamColor then |
2 | if Hit.Parent.Class.Value = = "Unit" then |
3 | for i,v in pairs (Selected) do |
4 | if v = = Hit.Parent then return end |
5 | end |
6 | table.insert(Selected,Hit.Parent) |
7 | end |
Could somebody explain where return "returns" to in these statements? If v == Hit.Parent
then will still insert Hit.Parent
into Selected
? Or does it "return" to the last end? Thanks!
return
is used in a function to stop everything. Every loop will stop. Nothing after return
will be read.
You can also use return
to cause a function to stop, and then give you a value. But this isn't what's happening in your code - it's just stopping.
You can read more on the wiki.