so i made an anti afk script, when you havent moved for more than 5 mins you get kicked.
let scoreMap = new Map()
system.runInterval(() => {
for (const source of world.getPlayers()) {
const { x, y, z } = source.location
const velocity = source.getVelocity()
let score = scoreMap.get(source) || 0
const blockBelow = source.dimension.getBlock({ x, y, z })
if (velocity.x === 0 && velocity.z === 0 || blockBelow.typeId === "minecraft:water") {
score++
} else {
score = 0
}
scoreMap.set(source, score)
source.onScreenDisplay.setActionBar(`${score}`)
if (score > 299) {
source.runCommandAsync(`kick ${source.name}`)
source.sendMessage(`${source.name} was kicked for being afk`)
}
}
}, 20)``` im running into some problems, so I want to test if the player is in water using some sort of afk device which moves you around aswell but im not sure on how to do.