-----[[Friaza's AFK timer system]]-----
--[[PLACE SCRIPT IN STARTERPACK --]}
1. Change "AfkTime" from '15' to the number of seconds
that you want the player to be AFK for.
2. "SpamLevel" is how often the AFK timer posts
player's AFK status to your "Output". I recommend
setting it between 1 (Once) and your AfkTime (Every second.)
]]
local AfkTime = 15
local SpamLevel = 5
local Timer = 0
local Player = game.Players.LocalPlayer
local mouse = game.Players.LocalPlayer:GetMouse()
local Afk = false
function NotAfk()
Timer = 0
if Afk == true then
Afk = false
Player.Character.ForceField:remove()
Player.Character.Torso.Anchored = false
print(Player.Name .." is back.")
end
end
mouse.KeyDown:connect(NotAfk)
mouse.KeyUp:connect(NotAfk)
mouse.Move:connect(NotAfk)
mouse.Button1Down:connect(NotAfk)
mouse.Button1Up:connect(NotAfk)
mouse.Button2Down:connect(NotAfk)
mouse.Button2Up:connect(NotAfk)
while wait(math.floor(AfkTime/SpamLevel)) do
if Timer < AfkTime then
Timer = Timer +AfkTime/SpamLevel
print("Player: " ..Player.Name .."'s AFK Timer: " ..Timer .." / " ..AfkTime ..".")
elseif (math.floor(Timer) == AfkTime or Timer == AfkTime or Math.cieling(Timer == AfkTime)) and Afk == false then
Afk = true
ff = Instance.new("ForceField", Player.Character)
Player.Character.Torso.Anchored = true
print(Player.Name .." is AFK.")
end
end
|