Kicking a player rather than killing a player in my anti-exploit

  1. I want to achieve it where my anti exploit kicks people instead of kills them.

  2. I made the anti-exploit, however I do not know how to change it so the player gets kicked instead of killed.

  3. I’ve tried looking for posts, but I cant so I thought making my own post could possibly work.

print("Pie's anti-exploit script loaded demo.")

me = script.Parent:FindFirstChild("Humanoid")

TestCounter = 0
lastTime = 0
lastState = 0

function checkstate(state)
	--// Jump hack prevention
	if state == Enum.HumanoidStateType.Seated then
		if lastTime > os.time() - 1 then
			TestCounter = TestCounter + 1
			
			if TestCounter > 2 then
				--// Kill the user
				me.Health = 0
				print(me.Parent.Name .. ", you were caught hacking.. :(")
			else
				print("Jump limiter: " .. TestCounter)
			end
		else
			lastTime = os.time()
			TestCounter = 0
		end
	end
	
	--// Fly hack prevention
	if state == Enum.HumanoidStateType.Flying then
		me.Health = 0
		print(me.Parent.Name .. ", you were just caught hacking.. :(")
	end
	
	--// Speed hack prevention
	if me.WalkSpeed > 16 then
		me.Health = 0
		print(me.Parent.Name .. ", you were just caught hacking.. :(")
	end
end


me.StateChanged:Connect(checkstate)

Thanks for looking, hopefully I can fix this soon! :smiley:

1 Like

What is this script a LocalScript or Script?

2 Likes

It’s a local script in StarterCharacterScripts.

I suggest that don’t use a Localscript when creating an anti-exploit script because exploiter can see the actual code of it and they can disable it.

2 Likes

Is there a better way to do it then?

Make multiple local scripts so if they disable 1 of the anti-exploit let the other anti-exploit detects it and kick em.

1 Like

Thanks for your feedback! :smiley:

Kicking on the Client is pretty bad, the exploiter might just disable the :Kick function. Teleporting them in the same game might work, but again, they can disable it on Client. Making an Anti Exploit on the Client may be good sometimes, place the anti exploit in a inportant Local Script(Something that the exploiter can do nothing without), so if he deletes it the game will be unplayable.

I’m new to making anti-exploits, but I will take your feedback!

1 Like

Not sure if it’s efficient though but I made something similar.
https://gyazo.com/5bd7065c4b78ee223c96da9ba9764b68

But I do suggest instead of kicking from the client use a server script instead.

1 Like

The exploiter can just hook the kick function

2 Likes

Yes, but if OP wants to create the Anti-Exploit on the client, the Exploiter may just disconnect all the connections from the Kick Remote(Please secure it, I don’t want a random Skid kick everyone). So the only thing you can do on the client without anyone advanced or not at exploiting just hooking Kick or anything else.

Well what I did was I made the client fire a remote that will send a message for the server to handle the rest of the kicking.

Screenshot_1

The encryption key is just so the exploiter could not fire the remote anyhow they want.

1 Like

The exploiter can hook the remote call too

1 Like

Should you have 2 scripts that do the same thing but have different names? So if they get past one, the other one kicks them instead?

1 Like

Wait exploiters can do that?!?!?!

1 Like

That whould just do unnecesary lag, and probably the exploiter can delete both. As I said, put the Anti-Exploit in a inportant script so when the Exploiter destroys it the game will become unplayable.

Also, @SelfDeclared Yes.

An exploiter can do pretty much anything that relates to the client

1 Like

So, I should make a different script that kicks them instead, so that when they disable the anti-exploit, they can still get kicked? :thinking:

1 Like

I’m not sure if you know how exploiting works. That is just inefficient and won’t really work at all.

1 Like