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

How can I calculate how long is a player doing an action?

Asked by 4 years ago
Edited 4 years ago

I am working on an anti-cheat and I want to know if a player keeps repeating the same action for a few seconds.

How can I calculate how long is a player doing an action? (Example: If a player is jumping for 5 seconds without stopping, or without touching the floor, the script will kill him) Thanks.

0
That would be a horrible anti-cheat herrtt 387 — 4y
0
It wasn't for the final version, I just wanted to try one thing. nanitook 13 — 4y

1 answer

Log in to vote
0
Answered by
haba_nero 386 Moderation Voter
4 years ago

This is a basic Anti-Cheat that covers basically everything, including health changes, jump changes, and speed changes.

Make this a SCRIPT and put it into PLAYERSCRIPTS

local Player = script.Parent
local Human = Player.Character:FindFirstChild("Humanoid")
Human.Changed:Connect(function()
    if Human.WalkSpeed > 16 then
        Player:Kick("Caught speed walking")
    elseif Human.JumpPower > 50 then
        Player:Kick("Caught changing jump power")
    elseif Human.Health > 100 then
        Player:Kick("Caught changing health")
    end
    wait(1)
end

And also, here is the script you requested: It stops a player from jumping more than once in five seconds. Put this one in PlayerScripts and make it a normal Script

local Player = script.Parent
local Human = Player.Character:FindFirstChild("Humanoid")
Human.Changed:Connect(function()
    if Human.Jump = true then
        Human.JumpPower = 0 
        wait(5)
        Human.JumpPower = 50
    end
end

Hope this helps!

0
Thanks! This help me a lot! nanitook 13 — 4y
Ad

Answer this question