How to make my other functions work

Here is the code. I created a table called players and added the sprite in function addbalo. When I took the sprite out of the scene:createScene. Every other function using it doesn’t work anymore. For instance the sprite player used to be part of ScreenGroup:insert(player) but when I moved it to a function so the timer would work, everything else using it doesn’t work any more.

Function sprite no longer works

local storyboard = require( “storyboard” )
local scene = storyboard.newScene()

local mydata = require( “mydata” )

local physics = require(“physics”)
physics.start()

players = {}

local function start(event)
if event.phase == “began” then
addbaloTimer = timer.performWithDelay(1000, addbalo, -1)

end
end
local function addbalo()
p_options =
{
– Required params
width = 237,
height = 252,
numFrames = 7,
– content scaling
sheetContentWidth = 1660,
sheetContentHeight = 252,

}

height = math.random(display.contentCenterX - 240, display.contentCenterY + 240)
playerSheet = graphics.newImageSheet( “balloon.png”, p_options )
player = display.newSprite( playerSheet, { name=“player”, loopCount=1 , start=1, count=7, time=500, loopDirection = “forward”} )
player.anchorX = 0.5
player.anchorY = 0.5
player.x = height
player.y = display.contentCenterY + 500
player.speed = 4
physics.addBody(player, “dynamic”, {density=3, bounce=0, friction=0.5})
player.gravityScale = -1
players:insert(player)

end

local function collide(event)
if event.phase == “began” then
storyboard.gotoScene(“play”, “fade”, 100)
end

end

local function sprite(event)
if event.phase == “began” then
players:play()
end

end

physics.setGravity(0, 9.8)

function scene:createScene( event )
local screenGroup = self.view

background = display.newImageRect(“bg.png”, 900, 1425)
background.anchorX = 0.5
background.anchorY = 1
background.x = display.contentCenterX
background.y = display.contentHeight
screenGroup:insert(background)

bar = display.newImageRect(“white.png”, 900, 50)
bar.anchorX = 0.5
bar.anchorY = 1
bar.x = display.contentCenterX
bar.y = display.contentHeight - 1400
screenGroup:insert(bar)
physics.addBody(bar, “static”, { friction=0.5, bounce=0})

end

function scene:enterScene( event )
background:addEventListener(“touch”, start)
bar:addEventListener( “collision”, collide )
players:addEventListener(“touch”, sprite)

end

function scene:exitScene( event )
background:removeEventListener(“touch”, start)
bar:removeEventListener( “collision”, collide )
players:removeEventListener(“touch”, sprite)

end

function scene:destroyScene( event )

end

scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “exitScene”, scene )
scene:addEventListener( “destroyScene”, scene )

return scene