What do you want to achieve?
I Want to make Anti Fling script, so exploiters won’t fling other players.
What is the issue?
I don’t know what’s wrong with my script.
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);
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…
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.
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);
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
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
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
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