Any time you see
local in front of a variable name, you're creating a new variable (type to be determined on the other side of the =).
Code:
local testFrame = CreateFrame("Frame", testFrame, UIParent)
Creates a new
Frame and assigns it to the testFrame variable of type
table (as previously noted, frames are tables)
Lua Code:
testFrame.texture = testFrame:CreateTexture()
Creates a new texture
Region and assigns it the texture key of testFrame. Same as:
Lua Code:
testFrame["texture"] = testFrame:CreateTexture()
But you can't add a key to a table that hasn't been created which is what
Code:
local testFrame.texture = testFrame:CreateTexture()
was trying to do (testFrame being nil at the time you get to the =).