Help with Anti-Exploits

So, I’m developing a sword fighting / fencing arena with my friend, and I’m working on an anti-exploit for the game.

Simple run-down: A script in the ServerScriptService adds a script into the player’s StarterPack. The script checks for if any changes are made to the player’s gear and such

I’m having trouble, because some people are randomly getting kicked for supposedly changing the GripPos, even though they arent. It’s only happening to a single person every so often. I’ve checked all of the other scripts in the game, and none of them change the GripPos.

Here’s the code that checks if the GripPos is changed:

while wait() do
wrap(function()
		-- Swords
		for _,v in pairs(SwordNames) do
			if Players.LocalPlayer.Character:FindFirstChild(v, false) then
				if Players.LocalPlayer.Character:WaitForChild(v, math.huge).GripPos ~= Vector3.new(0, 0, -1.5) then
					kick("Changing GripPos")
				end
			else
				if Players.LocalPlayer.Backpack:WaitForChild(v, math.huge).GripPos ~= Vector3.new(0, 0, -1.5) then
					kick("Changing GripPos")
				end
			end
		end
		-- Foils
		for _,v in pairs(FoilNames) do
			if Players.LocalPlayer.Character:FindFirstChild(v, false) then
				if Players.LocalPlayer.Character:WaitForChild(v, math.huge).GripPos ~= Vector3.new(0, 0, -2.05) then
					kick("Changing GripPos")
				end
			else
				if Players.LocalPlayer.Backpack:WaitForChild(v, math.huge).GripPos ~= Vector3.new(0, 0, -2.05) then
					kick("Changing GripPos")
				end
			end
		end
	end)()
end
end

Note that wrap() is referring to a variable, local wrap = corountine.wrap

Kicking the player seems a bit much. What if the script set the GripPos back to normal?

I think I’ll change it to reverting the settings. But, do you know of anything that might cause this?

Alright I’ll just set it as resolved. Thanks for the help :wink:

1 Like

It’s worth noting if you aren’t already to use things like magnitude checks on the sword and the player it hits, as with a touched event the hit is handled locally so it can be exploited pretty heavily without simple sanity checks. Also keep in mind they can still teleport to people so there’s tons of things to think about.

Your OP the script, it’s local so if you’re expecting it to be your only type of anti exploit. Expect it to be disabled.

1 Like