Disable AFK Kicking

I believe the way to do this is moving them to a different place and then teleporting them back right after
Just do that every 19 mins or whatever

I know that is one way people do

6 Likes

This should be possible by teleporting the player to the same game every 15~ minutes, this method does not work for 1 player servers though.

11 Likes

Hmm… You could use raycasting in the same way it is used for region based sounds. But instead of “playing a sound” when the player enters a region and “stopping the sound” when they leave the region you could “enable”/“disable” the localscript below inside their character…

while wait() do
	game:GetService("Players").LocalPlayer.Idled:connect(function()
		game:GetService("VirtualUser"):ClickButton2(Vector2.new())
	end)
end

Edit: This has ben tested and DOES work.

12 Likes

I played the game that was mentioned in this post, Kavras Kingdom, and they actually bypassed the AFK kick by teleporting you back into the game every 15 minutes or so, and then moving your character back into the AFK room (presumably by checking if you were coming from the AFK room before you were teleported).

So I’m assuming it is possible using TeleportService. But I’m not sure if this violates Roblox’s TOS as it is abusing premium payouts somehow? It allows premium users to abandon their computers and stay in your game for up to days on end without actually playing it…

3 Likes

I would like an official way to disable the inactivity kick, right now my users are forced to use auto clickers and such to keep themselves in my game Power n Chill. Which is a somewhat idle based game. I will look into this teleportservice trick and see if it works after detecting inactivity from the client.

In regards to “premium” payouts if it could already be “gamed” with someone using an autoclicker I don’t think it is a good reason to not be able to disable this. Maybe more checks from Roblox that there is an active user in their own client would be better. Though I suspect Roblox is already detecting if input is simulated or not and ignoring it for such things, which means they have “soft support” for not getting kicked already.

To encourage different game types like Power n Chill in Roblox you can’t have a typical blanket kicking out of users due to “inactivity”.

2 Likes

Server

local RejoinRemote = Instance.new("RemoteEvent")
RejoinRemote.Name = "RejoinRemote"
RejoinRemote.Parent = game.ReplicatedStorage

RejoinRemote.OnServerEvent:Connect(function(Player)
	local teleportData = {
		autoRejoin = true
	}

	local teleportOptions = Instance.new("TeleportOptions")
	teleportOptions.ServerInstanceId = game.JobId
	teleportOptions:SetTeleportData(teleportData)
	
	
    local attemptIndex = 0
    local success, result 
    repeat
        success, result = pcall(function()
            return game:GetService("TeleportService"):Teleport(game.PlaceId, { Player }, teleportOptions)
        end)
        attemptIndex += 1
        if not success then
            task.wait(2)
        end
    until success or attemptIndex == 4
end)


game.Players.OnPlayerAdded:Connect(function(Player)
	local JoinData = Player:GetJoinData()
	if JoinData.autoRejoin then
		-- Teleport to afk room
	end
end)

Local

local ReqMins = 17



local RejoinRemote = game.ReplicatedStorage:WaitForChild("RejoinRemote");
local Time = 0
game.Players.LocalPlayer:GetMouse().Move:Connect(function() Time = 0 end)
game:GetService("UserInputService").InputEnded:Connect(function() Time = 0 end)
ReqMins *= 60
while task.wait(1) do
	Time += 1;
	if Time >= ReqMins then
		RejoinRemote:FireServer()
		break
	end
end
6 Likes

what that dude posted up there works

while wait() do
	game:GetService("Players").LocalPlayer.Idled:connect(function()
		game:GetService("VirtualUser"):ClickButton2(Vector2.new())
	end)
end
1 Like
while wait() do
	game:GetService("Players").LocalPlayer.Idled:connect(function()
		game:GetService("VirtualUser"):ClickButton2(Vector2.new())
	end)
end

no one reading above replies, other guy alr solved this

2 Likes

Thanks kylerzong for saving me some effort, so this still works as of Sep 2023 ? You have it in production?

1 Like

Are you sure? Apparently it does not work any longer in a script, only in the command bar?

I get an error “The current thread cannot call ‘ClickButton2’ (lacking capability LocalUser)”

So not sure how it would be working anymore, the poster you quoted posted that in 2019.

1 Like

It does say that it doesnt work very well anymore

1 Like

For anyone wondering, the way Kavra’s Kingdom set up their afk room was by making the player rejoin

2 Likes

they posted it 11 months ago hahahaha it wasn’t 2019 11 months ago…

and YES you do get an error when using the script HOWEVER it does still work regardless of the error… test yourself here: AFK SQUARE - Roblox I setup an afk square to test it.

2 Likes

funny, cause its working fine for me

^^ anti-afk game… you can stand in the square forever without getting kicked for inactivity.

1 Like

I never said it didn’t work, only that it doesn’t work, well, well

1 Like

Ye ik, am just saying it still works for this method… it just doesn’t work anymore well for actually controlling the characters/client… but it will still give enough fake input to stop the game from idling a player.

1 Like

Yeah sorry I am not quite used to the forum, so I see Apr 19 and I am thinking the wrong thing. :smiley:

Anyhow I tested your place and it did seem to work, I checked after 10 minutes of being in the AFK square and I had a bunch of errors popping up in console, in a spam like fashion all in an instant, a screen worth. So I left it another 22 minutes, switched back to it and I hadn’t been kicked, however the Roblox client crashed on me about 5 seconds later when I was trying to open the console again, maybe due to the spam?

Do you need to spam the clicks for it to work, or is a single fake click at 19 minutes of AFK time enough? Whatever the answer is to that the fact these errors come up, and can even crash the client make it a bit of an icky solution IMO, but it is worthwhile to know it can work.

1 Like

haha no worries, ik their format/layout takes some getting used to.

anyway, unfortunately there is no way to stop the errors entirely as the error occurs because you cant simulate a click from server OR client…

but this is ok because its not the “click” that stops the idling, its the “attempt” to click that stops it.

as for crashing, if you don’t do it in a loop and just do

game:GetService("Players").LocalPlayer.Idled:connect(function()
	game:GetService("VirtualUser"):ClickButton2(Vector2.new())
end)

instead then there is less errors and less chance of your client crashing.

1 Like

So I tried it in my own game and it doesn’t work. I tried multiple things

  • Clickbutton2 once every 17 minutes
  • Clickbutton1 and Clickbutton2 every minute
  • Clickbutton1 and 2 in the idled event. I thought maybe the error in Idled event may be blocking the AFK code

All resulted in being kicked after 20 mins idle.

My game has no player characters, but Idled was stilled called every 2 minutes or so. But yeah, it appears not to work for me. The teleport trick does work for me at least.

1 Like

This code is pretty horrible because it creates a new Idle connection every wait() among other things.

Here is a better version, it detects when a player stops inputting, waits 1199 seconds, then clicks and breaks itself whenever the player starts inputting.

local UserInputService = game:GetService("UserInputService")

local elapsed = 0

UserInputService.InputBegan:Connect(function()
if connection then
connection:Disconnect()
connection = nil
elapsed = 0
end
end)

UserInputService.InputEnded:Connect(function()
local connection
connection = game.RunService.Heartbeat:Connect(function(delta)
elapsed += delta
if elapsed >= 1199 then
game:GetService("VirtualUser"):ClickButton2(Vector2.new())
elapsed -= 1199
end
end)
end)
1 Like