✓ Accepted answer
First, usage of and can be understood by the link given by @WideSteal321.
Second, usage of or in variables is important to counter nil. Let me explain the scripts that you have provided :
pointsDataStore:UpdateAsync(playerKey, function(oldValue)
local newValue = oldValue or 0
newValue = newValue + 50
return newValue
end)
The main usage of or comes to assign the variable the value of Part B, if Part A is nil. If someone is saving the value for the first time, oldValue won't exist, i.e., Part A would be nil. And if Part A is nil, it will assign variable newValue the value of Part B, i.e., 0.
Similar to your second script provided :
local character = player.Character or player.CharacterAdded:Wait()
Here, if the character of the player isn't loaded, then, player.Character would be nil and the variable character would be assigned the value of player.CharacterAdded:Wait(), i.e., the player's character.
NOTE You can skip this part if you know what player.CharacterAdded:Wait() does.
The main function of :Wait() is pause the script until the function before it is fired. CharacterAdded is fired when a player's character is added in the game world, i.e., when respawned or when a player joins the game for the first time and the character is added to world. :Wait() will make sure that no further script is executed until the player's character is added to the world.
Hope it helps!
1 comment
https://www.lua.org/manual/5.4/manual.html#3.4.5