With your advice, I was able to implement it successfully!
I’ve attached the code for those who have the same question.
This code will automatically display a 24x24 grid with no offset.
Thank you from the bottom of my heart!
-- Get the active sprite and assign it to the local variable <sprite>
local sprite = app.activeSprite
-- Specify an arbitrary Rectangle and assign it to the local variable <gridSize>
local gridSize = Rectangle(0, 0, 24, 24)
-- Assign the value of the Rectangle variable to sprite.gridBounds
sprite.gridBounds = gridSize