Simple AFK Script

Hi, can someone help me like what are the bascis about a simple AFK script ?

There are already tutorials, the script checks for player movement.

If you want to combat most anti-AFKing scripts, check for keyboard input and mouse input.

pretty much same as I said – player movement(vector & angles).

Some example of using it ?

Well, the vector is updated every time someone moves, even if they’re not pressing a bind. Same with angles

Thats why the afk script checks if the vector movement was made by the OWN player, or by somebody else, so what I said is true, so no reason to disagree.

Guys come on just give him one

The people shall learn to code, not top C+P…

Most “bigger” people will tell you that.

Just create a timer that checks every player’s position compared to a value which is indexed from their object(the player), and if it’s the same kick them. This is really basic to start out with.

I like your Avatar :3 – Also, wouldn’t that kick everybody as soon as they stand still exactly at the time the timer is ran?

Heh, funny how I said how simple it was, then suggested a solution that would never work. Thanks for pointing that out.
Here’s a version without that stupid mistake…

Create a timer that runs every minute. Grab every players position, set a variable on them with their position and another one with their afk time, as long as neither exist. If it does, check the player position with the position you set in your variable, and if it’s the same, add one to the time variable, however if it’s different reset the count to 0. Then, if the time variable equals 5, kick them.

Small note, you probably shouldn’t do posA == posB directly, it may yield false because of floating point rounding error crap, you should check if difference between them is smaller than some small value. Something like this:

local margin = 0.01
if posA:Distance(posB) <= margin then
    -- player is AFK

I see. Hadn’t thought of that, or every encountered that issue. Thanks for the tip.

You may be lucky and not encounter it actually. But it’s well known problem about comparing floating point values for equality so it’s better to account for that.

Couldn’t one use this function as well?