Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

2 comments

0

That would be a horrible anti-cheat

0

It wasn't for the final version, I just wanted to try one thing.

1 answer

✓ Accepted answer

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!

1 comment

0

Thanks! This help me a lot!

This discussion is preserved as it was. New answers, comments, and votes are closed.