Skip to content

A system health check for Roblox #221

@XXOTIC-1

Description

@XXOTIC-1

(Create a RemoteEvent in ReplicatedStorage named SystemCheckRemote)

-- ServerScriptService/SystemCheckServer.lua

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remote = ReplicatedStorage:WaitForChild("SystemCheckRemote")

local focusOffCounter = {}
local maxFocusLoss = 5 -- Number of times allowed to Alt+Tab before kick

remote.OnServerEvent:Connect(function(player, data)
if not data then return end

-- Handle focus loss tracking
if data.FocusLost then
	local count = (focusOffCounter[player.UserId] or 0) + 1
	focusOffCounter[player.UserId] = count

	warn("[Focus Lost] " .. player.Name .. " | Count: " .. count)

	if count >= maxFocusLoss then
		player:Kick("You have been kicked for switching windows too often.")
	end
	return
end

-- Handle system check
if data.SystemCheck then
	local info = data.SystemCheck
	print("[SystemCheck] " .. player.Name)
	print("  Device: " .. tostring(info.DeviceType))
	print("  Platform: " .. tostring(info.Platform))
	print("  Input: " .. tostring(info.InputType))
	print("  Time since join: " .. math.floor(info.TimePlayed) .. "s")
	print("  Network Ping: " .. tostring(info.Ping))
	print("  Memory Usage: " .. tostring(info.Memory) .. " MB")
end

end)

-- Reset focus counter on player leave
Players.PlayerRemoving:Connect(function(player)
focusOffCounter[player.UserId] = nil
end) (put this in server script)

-- StarterPlayerScripts/SystemCheckClient.lua

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local Stats = game:GetService("Stats")

local remote = ReplicatedStorage:WaitForChild("SystemCheckRemote")
local startTime = tick()

-- 📦 Send system info
local function sendSystemData()
local timePlayed = tick() - startTime
local memory = math.floor(Stats:GetTotalMemoryUsageMb())
local ping = math.floor(Stats.Network.ServerStatsItem["Data Ping"]:GetValue())
local device = UserInputService:GetPlatform()
local inputType = UserInputService.TouchEnabled and "Touch" or (UserInputService.KeyboardEnabled and "Keyboard" or "Gamepad")

remote:FireServer({
	SystemCheck = {
		DeviceType = device,
		InputType = inputType,
		Platform = UserInputService:GetPlatform().Name or "Unknown",
		TimePlayed = timePlayed,
		Ping = ping,
		Memory = memory,
	}
})

end

-- 🔁 Periodic system check every 30 seconds
task.wait(5)
sendSystemData()
while true do
task.wait(30)
sendSystemData()
end

-- 🔍 Focus lost detection (Alt+Tab or tab out)
UserInputService.WindowFocusReleased:Connect(function()
remote:FireServer({FocusLost = true})
end) (put this in local script and place it in starter scripts service)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions