Just want this said first. I haven’t seen a single post about this so that’s why I’m bringing this up. Anyways
Challenge 1 : Create a function that prints out the players WalkSpeed + the players Velocity
Challenge 2 : Create a function that loops trough a table and adds all the tables value together
*Note : 3 Integers inside the table,
The tables leftover arrays have to be sorted from biggest to smallest
Table example :
--//Example
local arrays = {
10, --[1]
25, --[2]
19 --[3]
}
Challenge 3 : Now that you’ve added up all the tables arrays i want you to use the example table as mentioned before, then i want you to find the largest Int inside of the table to then erase it from the table.
My solutions to the 2nd and the 3d challenge :
SPOILER !
repeat wait() until game:IsLoaded() --//love this
local arrays = {
10, --[1]
25, --[2]
19 --[3]
}
local i = 0 ---//declare our base value
local function addArrays()
for _, v in ipairs(arrays) do --//for loop the tables arrays
i = i + v --//add all the arrays together inside the table
end
print(i) --//print the declared variable(basically the tables values all together OUTSIDE the for loop)
end
local function removeArray()
table.sort(arrays, function(a, b) --//declare the tables path using table.sort and the returing the greatest value to set it to : 25, 19, 10
return a > b --//returns the tables arrays in the table.sort order 25, 19, 10
end)
table.remove(arrays, 1) --//remove the largest array that now is [1] or 25
print(arrays) --// the table will look something like this now : [1] = 19, [2] = 10
end
addArrays() --//call the created functions
removeArray() --//call the created functions