Hello devs
My problem is simpler than it looks, whenever I go to internet tutorials about scripts, the devs use a function similar to this: DataStore: SetAsync (Plr.UserId, information) function Load(Chr, Plr)
I don’t know how to ask but …
–what do these parentheses mean… ?
–what are the programmer is calling when you put these parentheses?
sorry if it wasn’t clear, but I really don’t know what to think about these situations
all_TY
For the first line of code, DataStore:SetAsync(plr.UserId, info) , since it is a proper Lua function, the two parameters HAVE to be given, it is made to take in these parameters. The first one being the key you use to set async, and the second one being what information you want to set. For the second one, it looks like a user made function called load, and the user has made it to take in two parameters. These can be used to call the function with values, an example:
function send(Name, str)
print(Name..""..str)
end)
send("AAD232007", "how are you?")
-- This will use that function by sending "AAD232007" as the name value in the function, and "how are you?" for the str. The function then uses these values to make a print statement so the output would be, AAD232007 how are you?
If you still don’t understand something, let me know!
That loops through a table. The i stands for the current index or the ‘key’ while the v stands for it’s value (You can change the variables to whatever you want but they still hold the same purpose).
For example, workspace.Part.BrickColor = BrickColor.Red()
“BrickColor” would be the key while “BrickColor.Red()” would be the value.
They can do to anything. In a user made function, anything inside the parentheses is just a value supplied to the function. You can use these values to do absolutely anything, from changing a part’s color, to printing a statement.
The parenthesis aren’t the table. They’re just used to hold the values for the function to use. You can however do this:
local function return_values(content)
local t = {} -- a temporary blank table to hold the values
for _, value in pairs(content) do
-- i used "_" for the index because i'm not going to use it (optional)
table.insert(t, value) -- this inserts the current value into the table
end
return table.unpack(t) -- this returns all of the values in the table
end
print(return_values { index = "value", one = "two"}) -- if your function expects a table, you can call it like this
-- prints "value", "two"