How could I prevent this from happening?

That’s gonna be a lot more difficult to patch.

Perhaps you could check everyone’s magnitude from one another on a localscript?
If one player (The exploiter) has everyone’s magnitude as 0 or 1, he’ll get kicked and only him or her since it’s client-sided and others won’t get teleported on their screen.

So essentially a loop magnitude checker on the client-sides.

1 Like

This is the exploit script I think

local players = getPlayer(args[1], speaker)
	for i,v in pairs(players)do
		task.spawn(function()
			if Players[v].Name ~= speaker.Name and not FindInTable(bringT, Players[v].Name) then
				table.insert(bringT, Players[v].Name)
				local plrName = Players[v].Name
				local pchar=Players[v].Character
				local distance = 3
				if args[2] and isNumber(args[2]) then
					distance = args[2]
				end
				local lDelay = 0
				if args[3] and isNumber(args[3]) then
					lDelay = args[3]
				end
				repeat
					for i,c in pairs(players) do
						if Players:FindFirstChild(v) then
							pchar = Players[v].Character
							if pchar~= nil and Players[v].Character ~= nil and getRoot(pchar) and speaker.Character ~= nil and getRoot(speaker.Character) then
								getRoot(pchar).CFrame = getRoot(speaker.Character).CFrame + Vector3.new(distance,1,0)
							end
							wait(lDelay)
						else 
							for a,b in pairs(bringT) do if b == plrName then table.remove(bringT, a) end end
						end
					end
				until not FindInTable(bringT, plrName)
			end
		end)
	end
end)

So basically it loopbrings players on the exploiters client and even if its not done on server the exploiter is still able to kill the players with a sword for example.

1 Like

Yeah, so if you locally check a player’s magnitude from other’s you could find one that stands out all of the sudden when the command is activated due to everyone teleporting to the exploiter.

Other players will be unaffected since as you said, the command is client-sided.

1 Like

Do you know how to do that? a serversided script for that would be amazing I am a beginner in scripting.

I would test it out and see if it works

1 Like

Serversided wouldn’t work since that would get all the magnitudes from the server’s view.

It’s like an anteater seeing an ant is alone (Server view) but there’s a whole colony (Exploiter’s view) under the ground.

2 Likes
local Table = {}
local players = game.Players

while task.wait(0.1) do
for i, plr in pairs(players:GetPlayers()) do
if plr.Character ~= nil then

table.insert(Table,plr.Name)

if plr.Character.Name ~= script.Parent.Name then
local Mag = (script.Parent.Torso.Position-plr.Character.Torso).Magnitude
if Mag < 6 then
table.remove(Table,plr.Name)
end
end
end
end
if #Table == 0 then
--Kick exploiter here like (script.Parent:Kick() or something.)
end 
end
1 Like

Should I make the localscript in workspace or put it in StarterPlayerScripts

I tried it in both and it doesnt seem to work

I would do localscripts in startercharacterscript.
Also are there any errors?

Sorry for the late reply.

1 Like

qwtqg
The code i am using is this

local Table = {}
local players = game.Players

while task.wait(0.1) do
	for i, plr in pairs(players:GetPlayers()) do
		if plr.Character ~= nil then

			table.insert(Table,plr.Name)

			if plr.Character.Name ~= script.Parent.Name then
				local Mag = (script.Parent.Torso.Position-plr.Character.Torso).Magnitude
				if Mag < 6 then
					table.remove(Table,plr.Name)
				end
			end
		end
	end
	if #Table == 0 then
		(script.Parent:Kick()
	end 
end

asd

checking the magnitude between the target and killer (server side) lower range = more false positive but more secure

Do you have a script for that? I am a complete beginner and almost done with my game all I need is a anticheat

in the damage function of the sword simply compare the distance between the two humanoid root parts since you get both the sword of the attacker and the humanoid of the target which you can then just redirect to the humanoid root part.
get distance by doing

(part1.Position-part2.Position).Magnitude

Would it be possible to create a seperate script for this that runs on the client or server?

Also this is my sword script if its possible to modify it

local config = {
	-- BASIC SETTINGS
	antiTeamkill = true;
	float = "none"; -- can be "none", "mid", or "full"
	slashDamage = 10; -- default 10
	lungeDamage = 40; -- default 50
	
	-- CHEAT SETTINGS
	pgsFix = true; -- lowers damage for the new PGS physics solver
	antiSwordChange = true; -- if true, prevents changing sword size, properties, etc
	antiTie = false; -- prevents killing once someone has died
	
	-- ADVANCED SETTINGS
	floatMatchesAnimation = false; -- if true, sword will be full float on OA, and no float on NA
	floatToolName = false; -- if true, the sword icon will be replaced with the type of float
	floatToolTip = true; -- if true, mousing over the sword displays the type of float
	mouseIcon = false; -- if true, displays the classic circle sword icon
	exposeConfig = true; -- creates a "config" folder in this script for in-game setting changes
}

--[[NEEDS DOING]] 

-- DO NOT EDIT BELOW THIS LINE

function new(typeOf, props)
	local obj = Instance.new(typeOf)
	for k, v in pairs(props) do
		obj[k] = v
	end
	return obj
end

local Debris = game:GetService("Debris")
local RunService = game:GetService("RunService")
local tool = script.Parent
local sword = tool.Handle
local acceptable = {"Head"; "Left Arm"; "Left Leg"; "Right Arm"; "Right Leg"; "Torso"}
local currDamage = config.slashDamage
local lastAttack = 0
local debounce
local floatChange
local sounds = {
	slash = new("Sound", {
		Name = "Slash";
		Volume = .7;
		SoundId = "rbxasset://sounds\\swordslash.wav";
		Parent = sword;
	});
	lunge = new("Sound", {
		Name = "Lunge";
		Volume = .6;
		SoundId = "rbxasset://sounds\\swordlunge.wav";
		Parent = sword;
	});
	unsheath = new("Sound", {
		Name = "Unsheath";
		Volume = 1;
		SoundId = "rbxasset://sounds\\unsheath.wav";
		Parent = sword;
	});
}

function getFloatName()
	return (config.float == "full" and "Full") or (config.float == "mid" and "Mid") or "No"
end

function canDamage(p1, p2)
	return config.antiTeamkill ~= true or p1.TeamColor ~= p2.TeamColor or p1.Neutral or p2.Neutral
end

function matches(name)
	for _, v in ipairs(acceptable) do
		if name == v then return true end
	end
	return false
end

function tagHumanoid(hum, player)
	local creator = Instance.new("ObjectValue")
	creator.Name = "creator"
	creator.Value = player
	creator.Parent = hum
	Debris:AddItem(creator, 1)
end

function damage(hum, damage, myPlayer)
	if config.pgsFix and debounce == true then return end
	debounce = true
	tagHumanoid(hum, myPlayer)
	hum:TakeDamage(damage)
	if config.pgsFix then
		wait()
		debounce = false
	end
end

function blow(hit)
	if hit.Parent == nil then return end
	if matches(hit.Name) then
		local myChar = tool.Parent
		local myPlayer = game.Players:GetPlayerFromCharacter(myChar)
		local myHum = myChar:FindFirstChild("Humanoid")
		local hitPlayer = game.Players:GetPlayerFromCharacter(hit.Parent)
		local hitHum = hit.Parent:FindFirstChild("Humanoid")
		if hitHum and myHum and hitHum ~= myHum and (not config.antiTie or myHum.Health > 0) then
			local arm = myChar:FindFirstChild("Right Arm")
			if arm then
				local joint = arm:FindFirstChild("RightGrip")
				if joint and (joint.Part0 == sword or joint.Part1 == sword) then
					if hitPlayer then -- real player
						if canDamage(myPlayer, hitPlayer) then
							damage(hitHum, currDamage, myPlayer)
						end
					else -- NPCs
						damage(hitHum, currDamage, myPlayer)
					end
				end
			end
		end
	end
end

function attack()
	currDamage = config.slashDamage
	sounds.slash:Play()
	local anim = Instance.new("StringValue")
	anim.Name = "toolanim"
	anim.Value = "Slash"
	anim.Parent = tool
end

function lunge()
	currDamage = config.lungeDamage
	sounds.lunge:Play()
	local anim = Instance.new("StringValue")
	anim.Name = "toolanim"
	anim.Value = "Lunge"
	anim.Parent = tool
	
	if config.float == "mid" or config.float == "full" then
		local root = tool.Parent and tool.Parent:FindFirstChild("HumanoidRootPart")
		if root then
			local floatVal = config.float == "full" and 2900 or 2328
			local force = Instance.new("BodyVelocity")
			force.Velocity = Vector3.new(0, 10, 0)
			force.MaxForce = Vector3.new(0, floatVal, 0)
			force.Parent = root
			Debris:AddItem(force, .5)
		end
	end
	
	wait(0.3)
	swordOut()
	wait(0.6)
	swordUp()
	currDamage = config.slashDamage
end

function swordUp()
	tool.GripForward = Vector3.new(-1,0,0)
	tool.GripRight = Vector3.new(0,1,0)
	tool.GripUp = Vector3.new(0,0,1)
end

function swordOut()
	tool.GripForward = Vector3.new(0,0,1)
	tool.GripRight = Vector3.new(0,-1,0)
	tool.GripUp = Vector3.new(-1,0,0)
end

function floatChanged()
	tool.ToolTip = config.floatToolTip and getFloatName() .. " Float" or ""
	if config.floatToolName == true then
		tool.TextureId = ""
		tool.Name = getFloatName() .. "Float"
	end
end

function determineAnimation(char)
	local isOA = true
	for _, c in ipairs(char:GetChildren()) do
		if c:IsA("LocalScript") and c:FindFirstChild("walk") and c:FindFirstChild("sit") then
			isOA = false
		end
	end
	return isOA and "OA" or "NA"
end

tool.Activated:connect(function()
	--print"activated"
	local char = tool.Parent
	local hum = char:FindFirstChild("Humanoid")
	if not tool.Enabled then return end
	if not hum then return end
	
	tool.Enabled = false
	
	local t = RunService.Stepped:Wait()
	if t - lastAttack < .2 then lunge() else attack() end
	lastAttack = t
	
	tool.Enabled = true
end)

tool.Equipped:connect(function()
	sounds.unsheath:Play()
	
	if (not floatChange or floatChange.Value == "") and config.floatMatchesAnimation then
		local char = tool.Parent
		if char and char:IsDescendantOf(workspace) then
			local anim = determineAnimation(char)
			config.float = anim == "OA" and "full" or "none"
			floatChanged()
		end
	end
	
	local player = game.Players:GetPlayerFromCharacter(tool.Parent)
	sword:SetNetworkOwner(player)
end)

-- START UP
if config.exposeConfig and tool:FindFirstChild("SwordScript") then
	local vFolder = new("Folder", {Name = "config"})
	floatChange = new("StringValue", {Name = "float"; Value = ""; Parent = vFolder})
	floatChange:GetPropertyChangedSignal("Value"):connect(function()
		config.float = floatChange.Value
		floatChanged()
	end)
	vFolder.Parent = tool.SwordScript
end
local cFolder = new("Folder", {Name = "config"})
new("BoolValue", {Name = "icon"; Value = config.mouseIcon == true; Parent = cFolder})
new("BoolValue", {Name = "change"; Value = config.antiSwordChange == true; Parent = cFolder})
floatChanged()
cFolder.Parent = tool.client
tool.Enabled = true
sword.Touched:connect(blow) -- toggle damaging
1 Like

Try replacing your current damage function with this modified one

function damage(hum, damage, myPlayer)
	if config.pgsFix and debounce == true then return end
	debounce = true
	local hitHrp = hum.Parent:FindFirstChild("HumanoidRootPart")
	local maxRange = 15
	tagHumanoid(hum, myPlayer)
	if hitHrp and (tool.Parent.HumanoidRootPart.Position-hitHrp.Position).Magnitude <= maxRange then
		hum:TakeDamage(damage)
	end
	if config.pgsFix then
		wait()
		debounce = false
	end
end
2 Likes

But now the damage doesnt work hmm

1 Like

Script.Parent:Kick() won’t work, you’ll need to fire an event to the server for the server to kick.

1 Like

Can you show me a script example how? I am glad i signed up on the forum since i am learning alot now

1 Like

You would need to add a remote event into ReplicatedStorage and name it “Hecker”. (Don’t ask why I named it that.

Put this in the localscript

local Table = {}
local players = game.Players

while task.wait(0.1) do
for i, plr in pairs(players:GetPlayers()) do
if plr.Character ~= nil then

table.insert(Table,plr.Name)

if plr.Character.Name ~= script.Parent.Name then
local Mag = (script.Parent.Torso.Position-plr.Character.Torso).Magnitude
if Mag < 6 then
table.remove(Table,plr.Name)
end
end
end
end
if #Table == 0 then
game.ReplicatedStorage.Hecker:FireServer()
end 
end

Put this in a server script in serverscriptservice

game.ReplicatedStorage.hecker.OnServerEvent:Connect(function(plr)
plr:Kick(“hacker lol”)
end)
1 Like