Disable Roblox's anti AFK system

Hi, I’m currently making a game that involves idling for some time, but Roblox’s anti-afk system is messing things up. I came up with this solution:

local rs = game:GetService("ReplicatedStorage")
local plrs = game:GetService("Players")
local ts = game:GetService("TeleportService")
local ws = game:GetService("Workspace")

local afkZone = ws.AFKZONE

rs.Remotes.AFKTrigger.OnServerEvent:Connect(function(player: player)
	local data = {
		autoRejoin = true
	}
	
	local options = Instance.new("TeleportOptions")
	options.ServerInstanceId = game.JobId
	options:SetTeleportData(data)
	
	ts:Teleport(game.PlaceId, player, options)
end)

plrs.PlayerAdded:Connect(function(player: Player)
	local data = player:GetJoinData()
	if data.autoRejoin then
		local char = player.Character or player.CharacterAdded:Wait()
		task.wait(2)
		
		char:PivotTo(afkZone.CFrame)
	end
end)

The “AFKTrigger” remote event is called using Player.Idled event every 19 minutes.
However, if there’s only one player in the server, the server shuts down and player is unable to re-connect automatically.

Any ideas?

You can only make the Player Rejoin the game by sending him to Places.
if hes idle then hes idle, nothing to do about it.
maybe save TeleportData of player what hes doing and thats it.

I want to disable Roblox’s anti AFK system, or at least bypass it…
Here’s the question for clarity:

Doesn’t work.

1 Like

What do you mean by that :v
123456789

That’s how a Roblox server functions. I’m not sure there’s a way to make it so it doesn’t shutdown.

That said, you could make a new server that the one player would teleport to.

How would I do that?
1231241232423

Look at this rejoin command.

local players = game:GetService('Players')
local teleportService = game:GetService('TeleportService')
local textChatService = game:GetService('TextChatService')

local commands = textChatService:WaitForChild('TextChatCommands')

local rejoinCommand = Instance.new('TextChatCommand')
rejoinCommand.PrimaryAlias = '/rejoin'
rejoinCommand.Parent = commands

rejoinCommand.Triggered:Connect(function(source, text)
	local userId = source.UserId
	
	local player = players:GetPlayerByUserId(userId)
	
	if not player then
		return
	end
	
	local playersCount = #players:GetPlayers()
	
	local teleportOptions
	
	if playersCount > 1 then --[[	we check for the number of players to be greater than 1 
									because when we try joining this server, it will have 
									already been marked as shutting down (we will encounter 
									an inf. load), so we need to teleport them to a new server,
									thus we want to not pass a TeleportOptions so we get the default
									teleporting behaviour.
									
									don't believe there's a way to get around the server shutdown behaviour ]]
		teleportOptions = Instance.new('TeleportOptions')
		teleportOptions.ServerInstanceId = game.JobId
	end

	teleportService:TeleportAsync(game.PlaceId, { player }, teleportOptions)
end)
1 Like

image
Same thing, I guess more server’s should be running to make this work lol

Yeah, So instead of using

options.ServerInstanceId = game.JobId

Maybe try

options.ShouldReserveServer = true

That way, instead of trying to teleport back to the same server they left, they will instead go to a new reserved server.

I use a similar method, but I also send them back from the reserved server to a public server.

Could be a better way… but… idk yet

I’m going to be honest, even if you do find a way to bypass this, the chances are that roblox will patch it sooner or later. Roblox doesn’t want you to afk for long periods of time because it costs them a ton of money to maintain the servers, so they of course cut any unnecessary connection. I would rather look into the design of your game for a way so you don’t have to deal with this issue at all, because this just look like a game design flaw to me.

1 Like

And how do you do that?
1231232131221

Pretty much the same way that we used to handle soft shut-downs.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.