Trying to make AntiFling script

  1. What do you want to achieve?
    I Want to make Anti Fling script, so exploiters won’t fling other players.

  2. What is the issue?
    I don’t know what’s wrong with my script.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve found something on devforum, but it won’t work.

local Players = game:GetService("Players");
local RS = game:GetService("RunService");

task.spawn(function()
	while true do
		for _, player in pairs(Players:GetPlayers()) do
			if player.Character then
				local char = player.Character;
				local hrp = char:FindFirstChild("HumanoidRootPart");
				
				if hrp then
					if hrp.Velocity.Magnitude > 60 then
						player:Kick("You can't be here");
					end;
				end;
			end;
		end;
		RS.Heartbeat:Wait();
	end;
end);

Thanks for help!

2 Likes

Realised, that if i will jump from high place, this script will kick me, so i need help

1 Like

That “fling” exploit ppl is using I guess its based on adding a force/bodyMover like BodyThrust into their HumanoidRootPart, and collide against another player to push them. Right?

  • A very basic solution could be, disable collisions between players
  • If you prefer to continue with your approach, maybe set the max magnitude more than 60, so it wont read a fall of the player, as far as I understand, surely they are using higher speed to actually throw a player.
  • Im thinking on “weird” ways to achieve it… but surely are not good practice…
    Reading player’s collisions? if a player gets “flinged” read the last player collision they had… And based on how many times that the same player (the exploiter) was the last one, kick.
    Or… when someone gets a very high manitude speed, quickly inject a local script into them, which will call a remote event to send all the descendants names inside player character to server, and if you find something that should not be there (like a BodyMover) then kick…

Idk… sometimes patching this kind of exploits its really hard…

2 Likes

I won’t disable collision between players, because this will break some functions in my game, but i also realised, that script wont kick the exploiter, it will player that was flinged by exploiter, because players velocity sets to millions.

so i does something like this:

local Players = game:GetService("Players");
local RS = game:GetService("RunService");

task.spawn(function()
	while true do
		for _, player in pairs(Players:GetPlayers()) do
			if player.Character then
				local char = player.Character;
				local hrp = char:FindFirstChild("HumanoidRootPart");
				local hum = char:FindFirstChildOfClass("Humanoid");
				local count = 0;
				local lastTouch;
				
				hum.Touched:Connect(function(part)
					lastTouch = part;
					count += 1;
				end);
				
				if hrp.Velocity.Magnitude > 2000 then
					if lastTouch and Players:GetPlayerFromCharacter(lastTouch.Parent) and count > 5 then
						local exploiter = Players:GetPlayerFromCharacter(lastTouch.Parent);
						exploiter:Kick("Тебе здесь запрещено: @");
					end;
				end;
			end;
		end;
		RS.Heartbeat:Wait();
	end;
end);

Didn’t tested it yet, but i’ll say if it worked.

What if the “flinged” player collides with another normal player, after being pushed? You would be kicking the normal player, a false positive

With an approach like that, I would suggest using a table of possible “exploiters”, and save into that table the times that a player has been behind the “fling attack”, if a player gets enough times into that table then kick

1 Like

i don’t think normal player can push other player by 1000’s of studs. But still ill change the number to 10K

No I mean, the exploiter, push the player, the victim starts movement, but its magnitude its not 2000 yet, the victim collides against a normal player, then the victim gets the 2k magnitude, your script would be kicking the normal player (the last one that collided) and not the exploiter

1 Like

well i does that after 2 seconds lastTouch sets to nil. But for some reasons, game just freezes after a while, i think because of while loops.

tried something like this, but it’s freezes the whole game, do you know what the problem with this script?:

local Players = game:GetService("Players");
local RS = game:GetService("RunService");

task.spawn(function()
	while true do
		for _, player in pairs(Players:GetPlayers()) do
			if player.Character then
				local char = player.Character;
				local hrp = char:FindFirstChild("HumanoidRootPart");
				local hum = char:FindFirstChildOfClass("Humanoid");
				local count = 0
				local lastTouch;
				
				hum.Touched:Connect(function(part)
					lastTouch = part;
					count += 1;
					delay(2, function()
						lastTouch = nil;
						count = 0;
					end);
				end);
				
				if hrp.Velocity.Magnitude > 10000 then
					if lastTouch and Players:GetPlayerFromCharacter(lastTouch.Parent) and count > 5 then
						local exploiter = Players:GetPlayerFromCharacter(lastTouch.Parent);
						exploiter:Kick("Тебе здесь запрещено: @");
						break;
					end;
				end;
			end;
		end;
		wait(0.5);
	end;
end);

First, you are Connecting the Touched event lot of times, each 0.5 seconds lots of new connections.

Your while loop is iterating all players in game, for each one, connect the touch event, and when the player’s list is over, it starts again with the same task, iterate all players and connect again that touched function, resulting in useless connections, memory leak

2 Likes

ok, i’m about to try something like this:

local Players = game:GetService("Players");
local RS = game:GetService("RunService");

Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local hrp = char:FindFirstChild("HumanoidRootPart");
		local hum = char:FindFirstChildOfClass("Humanoid");
		local lastTouch;
		local count = 0;
		
		hum.Touched:Connect(function(part)
			lastTouch = part;
			count += 1;
			delay(2, function()
				lastTouch = nil;
				count = 0;
			end);
		end);
		
		hrp:GetPropertyChangedSignal("Velocity"):Connect(function()
			if lastTouch and count > 5 and hrp.Velocity.Magnitude >= 5e3 then
				local probExploiter = Players:GetPlayerFromCharacter(lastTouch.Parent);
				if probExploiter then
					probExploiter:Kick("Not today");
				end
			end;
		end);
	end);
end);

Honestly, I dont think that gonna work as intended, but maybe you are getting closer to something that works.
One thing to notice is that you are connecting the touch event to the Humanoid, and that instance has not collision functions, you are looking for the HumanoidRootPart maybe to connect the touch event

2 Likes

i will try it, thanks for keeping helping me!

3 Likes

yeah, it didn’t worked… I Have no ideas how to make anti fling anymore tho

1 Like

just don’t take into consideration of the Y axis

2 Likes

that’s looks like a great idea, will try it!

1 Like

manipulating with velocity will kick the player, who got flinged by an exploiter, i need other method to make my script get who’s the flinger

1 Like

just have a local script and put an x and z velocity magnitude check inside a while task.wait() do statement

1 Like

i think instead of using

hrp.Velocity.Magnitude > 60

you should use

(math.abs(hrp.Velocity.X)+math.abs(hrp.Velocity.Y)+math.abs(hrp.Velocity.Z)) > 60