main.lua:39: attempt to call method 'setLinearvelocity' (a nil value)

Im having trouble with my game that I am making which is like a ping pong game where when the ball touches the blocks but I keep having a problem where its saying setLinearvelocity is a nil value if anyone could help please do.

local w = display.contentWidth

local h = display.contentHeight

local fisica = require(“physics”)

fisica.start()

fisica.setGravity(0,0)

local bg = display.newRect(w/2,h/2,w,h)

local pg = display.newRoundedRect(w/2,h-h/20,w/4,h/30,30)

pg:setFillColor(0,0,0)

fisica.addBody(pg, “static”)

local function movePg(event)

pg.x = event.x

end

Runtime:addEventListener(“touch”, movePg)

local larghezza = w/6 - w/20

local altezza = h/20 - h/30

for i=1,5,2 do

for j=1,11,2 do

local enemy = display.newRoundedRect(w/12*j,h/20*i,larghezza,altezza,30)

enemy:setFillColor(0,0,0)

fisica.addBody(enemy, “static”)

local function collisione(self, event)

self:removeSelf()

end

enemy.collision = collisione

enemy:addEventListener(“collision”)

end

end

local ball = display.newCircle(w/2,h/2,w/40)

ball:setFillColor(0,0,0)

fisica.addBody(ball, “dynamic”, {bounce=1})

ball:setLinearvelocity(w/2, w/2)

local wallSx = display.newRect(w/20,h/2,w/10,h)

local wallDx = display.newRect(w*w/20,h/2, w/10, h)

fisica.addBody(wallSx, “static”)

fisica.addBody(wallDx, “static”)

  1. Please format code posts.  Also, help us out in the future by marking the line in question so we don’t have to count or find it on our own.

formatyourcode.jpg

  1. It means the object wasn’t created or the body wasn’t added (the latter this time).

Update: SEE DAVE’s answer below for actual problem.

  1. This is the problem:

    fisica.addBody(ball, “dynamic”, {bounce=1}) – what is fisica? I think you mean physics

needs capital “V”, Lua is case-sensitive

Dave is right.  Also I just noticed this:

local fisica = require("physics")

Thus explaining your non-standard (but still correct) code for the addBody() statements.

  1. Please format code posts.  Also, help us out in the future by marking the line in question so we don’t have to count or find it on our own.

formatyourcode.jpg

  1. It means the object wasn’t created or the body wasn’t added (the latter this time).

Update: SEE DAVE’s answer below for actual problem.

  1. This is the problem:

    fisica.addBody(ball, “dynamic”, {bounce=1}) – what is fisica? I think you mean physics

needs capital “V”, Lua is case-sensitive

Dave is right.  Also I just noticed this:

local fisica = require("physics")

Thus explaining your non-standard (but still correct) code for the addBody() statements.