I found the answer. Here's the code
function love.update(dt)
if (player.x>735) then
if (love.keyboard.isDown('left') or love.keyboard.isDown('a') or love.keyboard.isDown('right') or love.keyboard.isDown('d')) then
player.x=player.x-(player.speed*dt)
end
elseif (player.x<-10) then
if (love.keyboard.isDown('left') or love.keyboard.isDown('a') or love.keyboard.isDown('right') or love.keyboard.isDown('d')) then
player.x=player.x+(player.speed*dt)
end
else
if (love.keyboard.isDown('right') or love.keyboard.isDown('d')) then
person.x=person.x+(person.speed*dt)
elseif (love.keyboard.isDown('left') or love.keyboard.isDown('a')) then
person.x=person.x-(person.speed*dt)
end
end
end
It might seem like it won't fix it, but it fixed it for me. I just set it that if he's at the edge, it won't let him go further.