Hi everyone, I have a problem with my AFK system: while testing everything, when a player goes AFK all the others in the server go AFK in the same way. I know it’s a problem with the Server Script but I really can’t fix it. A reference to what happens: https://gyazo.com/40fc9dbdf3b1760f891914cbb2bb5710
I’ve already tested it with two real players and the same happens.
Script (in ServerScriptService):
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
remoteEv.OnServerEvent:Connect(function(plr, isAFK)
if isAFK then
plrTag.PlayerName.Text = "AFK | "..player.Name
elseif not isAFK then
plrTag.PlayerName.Text = player.Name
end
end)
end)
end)
LocalScript (in StarterPlayerScripts):
local UserInputService = game:GetService("UserInputService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteEv = replicatedStorage.SistemiBase:WaitForChild("AFKSystem")
UserInputService.WindowFocusReleased:Connect(function()
remoteEv:FireServer(true)
end)
UserInputService.WindowFocused:Connect(function()
remoteEv:FireServer(false)
end)