This script allows players in your game to safely go AFK if they need to do something like go down for dinner
Disclaimers
I’m not an advanced lua scripter by any means, but I thought I could try to make this system for the fun of it to release on here, so please don’t ask me to script something for you or criticize on it if it’s bad and “simple”
How do we (you guys) get it?
Just follow the steps below!
Step 1
Download the main afk system script from here. If you wish to download the pre-build AFK zone, download it from here
Step 2
Open your game and put the main afk system script in ServerScriptService and the pre-build AFK zone (if downloaded) into Workspace
Step 3
Once completed, open the script that you placed in ServerScriptService. Once opened, you will see configuration variables. The explanation of these variables is already in the script, so I don’t need to explain them here
Step 4
You’re done! If you want to make your own custom AFK zone, read the requirements below
Requirements for custom AFK zone by default
Must be placed in game.Workspace
Must be named “AFK Place”
Must be a model
Must have a part called “Spawn” in the model
Video Showcase
Video Showcase: zachariapopcorn.is-winning.xyz/4Np8LUcutB.mp4
Conclusion of Post
Thanks for reading my post on my AFK system. If you do like this, show your kindness by liking this post, or spreading this post, it’s up to you. If you wish to add something to this script, make a PR on the Github or make a suggestion in the replies, I’m all ears. Anyways, good day and good bye.
Let’s say we put this on a game such as a fighting game (With specific properties.). If the player were to say !afk, and then later, do !unafk, they would be fully healed. This could potentially lead to problems. Also, what if they were to do !afk, while their character was reset/dead? Not sure if this can bring a problem, but I think it’d throw an error or so.
A potential fix to the first problem, is to turn this into a module, then make a function which disables the use of the command !afk, such as: AFKSysModule:DisableCommand(true). The given argument would be a boolean, being true, the !afk command, and false, the !unafk command. Or maybe just use some string.
I counted for this when I wrote it, change the value to true for the pvpGame variable in the script
I see how this can be a problem with the setting off/false, but if they do !afk with the setting true, it will check if the player’s current health is equal to the player’s maxhealth. If it is, it teleports, if not, then it doesn’t do anything
Oh, that’s really good. Just by seeing how much things you done to make things, make me feel like this is actually well made. Also, what you do to make the player afk? Just teleport them to a afk zone? Because, from what I remember, in Roblox, if you are idle for 20 minutes, you get disconnected. What I mean is, what you do to prevent this?
I don’t think there is a way to prevent that as I heard that it uses the .Idle (or whatever it’s name is) event in the UserInputService, and forcing a player to jump still makes the game think they are idle. This is just what I’ve heard
Actually, there is a way. You can use game:GetService("Players").LocalPlayer.Idled and the Roblox service VirtualUser to send inputs. I know it works because I use it in a meme game I made.
local vu = game:GetService("VirtualUser")
game:GetService("Players").LocalPlayer.Idled:connect(function()
vu:Button2Down(Vector2.new(0,0),workspace.CurrentCamera.CFrame)
wait(1)
vu:Button2Up(Vector2.new(0,0),workspace.CurrentCamera.CFrame)
end)
Just add a simple check for you AFK variable within the idle and you’re good to go
Could you please make a Github repro for this for all the people that don‘t want to download the file (it isn‘t like I don‘t trust you, but if you are on mobile for example, how could you look at the code…)