Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

For loop to check for increased walkspeed doesnt work?

Asked by 3 years ago

I'm trying to make an AntiCheat system, but nothing happens when I increase my WalkSpeed.

for i, player in pairs(game.Players:GetPlayers()) do
    wait(timeBetweenScans)
    local cheaters = {}
    if outputInfo == true then
        print("Performing a Cheat Scan...")
    end
    if antiSpeed == true then
        if player.Character.Humanoid.WalkSpeed > maxSpeed then
            player:Kick(speedReason)
        end
    end
    if antiJump == true then
        if player.Character.Humanoid.JumpPower > maxJump then
            player:Kick(jumpReason)
        end
    end
    if antiGod == true then
        if player.Character.Humanoid.MaxHealth > maxHealth then
            player:Kick(godReason)
        end
    end
    if outputInfo == true then

    end
end
0
Unused variable 'cheaters', recommend to remove it antoniorigo4 117 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Hello there! I believe the current state of your script will only perform at the beginning of the game. What you may want to do is add a while loop before the for loop, so it is checking constantly.

while wait(0.1) do 
    for i, player in pairs(game.Players:GetPlayers()) do
        local cheaters = {}
        if outputInfo == true then
                print("Performing a Cheat Scan...")
            end
            if antiSpeed == true then
                if player.Character.Humanoid.WalkSpeed > maxSpeed then
                    player:Kick(speedReason)
                end
            end
            if antiJump == true then
                if player.Character.Humanoid.JumpPower > maxJump then
                    player:Kick(jumpReason)
                end
            end
            if antiGod == true then
                if player.Character.Humanoid.MaxHealth > maxHealth then
                    player:Kick(godReason)
               end
               end
            if outputInfo == true then

        end
    end
end

Let me know if this works. You can also try using PropertyChangedSignal to see when the humanoid's properties change value. Read more about it here: (http://developer.roblox.com/en-us/api-reference/function/Instance/GetPropertyChangedSignal)

Ad
Log in to vote
0
Answered by
ew_001 58
3 years ago
Edited 3 years ago

Remember, a server script can not see if you are changing walk speed on the client, it will remain the same for the server.

To fix this, change this into a local script, that only checks on the local player. But this comes with a problem, the exploiter can disable the local script.

But the local script can still catch most exploiters if they don not see the local script.

A tip on disguising the local script is by renaming to someting else then "AntiCheat" or "AntiExploit", and do not rename it to like someting wierd or scrambled, because thats suspicious.

Rename it to like "ClientReplicator" or "ClientMethods".

I hope this helps!

Answer this question