In your code there are 2 variables that shows the width and height of a tile. They both are equal to 50. What I reccomend you to do is creating a new variable tileSize or tileSide. It will be more easy to work with it.
So we want to get player's X and Y linked to map grid:
Code: Select all
x = math.floor(playerx/tileSize)
y = math.floor(playery/tileSize)
P.S. Please, quote next time.