Releasing my Anti-Void

Hello, it’s became clear to me that some players still are having trouble with exploiters sending players to the void in their games. I have come with a patch for that, simply a server script in SSS.

local Players = game:GetService("Players");
local WaitTime, DetectedPlayers = 2.5, {};

function Connect(func, ...)
    return func:Connect(...)
end

function newThread(func, ...)
    return coroutine.wrap(func)(...)
end

function CharacterCheck(Character)
    if not Character then return end
    if not Character:FindFirstChild("HumanoidRootPart") then return end
    return Character
end

function getHumanoid(Character)
    if not Character then return end
    if not Character:FindFirstChild("Humanoid") then return end
    if Character.Humanoid.Health <= 0 then return end
    return Character.Humanoid
end

local PlayersConnection = Connect(Players.PlayerAdded, function(player)
    Connect(player.CharacterAdded, function(char)
        char:WaitForChild("Humanoid", 5)
        
        char.DescendantRemoving:Connect(function(desc)
            if desc:IsA("Humanoid") then
                player:Kick()
            end
        end)
    end)
end)

newThread(function()
    while task.wait(WaitTime) do
        for _, Player in next, Players:GetPlayers() do
            local Character = CharacterCheck(Player.Character)
            
            if Character then
                local Humanoid = getHumanoid(Character)
                
                if not Humanoid then
                    table.insert(DetectedPlayers, Player)--this is here for my flagging exploiters command
                end
            end
        end
    end
end)
9 Likes

edit: thank you bin for telling me about network ownership

2 Likes

Why is this called func?

Why not use task.spawn?

2 Likes

i took it into consideration but I just would rather using coroutine, because i had my antivoid in a way bigger script of mine which also uses newThread() for other functions

1 Like

task.spawn uses coroutines just fine.

cool line. I couldn’t understand any lines of your code bro. Please explain step by step.