I've revamped it a little bit:
function onStepIn(cid, item, pos)
local newPosition = {x = position.x, y = position.y, z = position.z}
local reqLevel = 2000
if getPlayerLevel(cid) >= reqLevel then
doPlayerSendTextMessage(cid, 22, 'You can pass safely.')
else
newPosition.y =...