Advertisement
MayDayZen

AntiFling

Nov 20th, 2021
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.20 KB | None | 0 0
  1. -- // Constants \\ --
  2. -- [ Services ] --
  3. local Services = setmetatable({}, {__index = function(Self, Index)
  4. local NewService = game.GetService(game, Index)
  5. if NewService then
  6. Self[Index] = NewService
  7. end
  8. return NewService
  9. end})
  10.  
  11. -- [ LocalPlayer ] --
  12. local LocalPlayer = Services.Players.LocalPlayer
  13.  
  14. -- // Functions \\ --
  15. local function PlayerAdded(Player)
  16.    local Detected = false
  17.    local Character;
  18.    local PrimaryPart;
  19.  
  20.    local function CharacterAdded(NewCharacter)
  21.        Character = NewCharacter
  22.        repeat
  23.            wait()
  24.            PrimaryPart = NewCharacter:FindFirstChild("HumanoidRootPart")
  25.        until PrimaryPart
  26.        Detected = false
  27.    end
  28.  
  29.    CharacterAdded(Player.Character or Player.CharacterAdded:Wait())
  30.    Player.CharacterAdded:Connect(CharacterAdded)
  31.    Services.RunService.Heartbeat:Connect(function()
  32.        if (Character and Character:IsDescendantOf(workspace)) and (PrimaryPart and PrimaryPart:IsDescendantOf(Character)) then
  33.            if PrimaryPart.AssemblyAngularVelocity.Magnitude > 50 or PrimaryPart.AssemblyLinearVelocity.Magnitude > 100 then
  34.                if Detected == false then
  35.                    game.StarterGui:SetCore("ChatMakeSystemMessage", {
  36.                        Text = "Fling Exploit detected, Player: " .. tostring(Player);
  37.                        Color = Color3.fromRGB(255, 200, 0);
  38.                    })
  39.                end
  40.                Detected = true
  41.                for i,v in ipairs(Character:GetDescendants()) do
  42.                    if v:IsA("BasePart") then
  43.                        v.CanCollide = false
  44.                        v.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
  45.                        v.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
  46.                        v.CustomPhysicalProperties = PhysicalProperties.new(0, 0, 0)
  47.                    end
  48.                end
  49.                PrimaryPart.CanCollide = false
  50.                PrimaryPart.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
  51.                PrimaryPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
  52.                PrimaryPart.CustomPhysicalProperties = PhysicalProperties.new(0, 0, 0)
  53.            end
  54.        end
  55.    end)
  56. end
  57.  
  58. -- // Event Listeners \\ --
  59. for i,v in ipairs(Services.Players:GetPlayers()) do
  60.    if v ~= LocalPlayer then
  61.        PlayerAdded(v)
  62.    end
  63. end
  64. Services.Players.PlayerAdded:Connect(PlayerAdded)
  65.  
  66. local LastPosition = nil
  67. Services.RunService.Heartbeat:Connect(function()
  68.    pcall(function()
  69.        local PrimaryPart = LocalPlayer.Character.PrimaryPart
  70.        if PrimaryPart.AssemblyLinearVelocity.Magnitude > 250 or PrimaryPart.AssemblyAngularVelocity.Magnitude > 250 then
  71.            PrimaryPart.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
  72.            PrimaryPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
  73.            PrimaryPart.CFrame = LastPosition
  74.  
  75.            game.StarterGui:SetCore("ChatMakeSystemMessage", {
  76.                Text = "You were flung. Neutralizing velocity.";
  77.                Color = Color3.fromRGB(255, 0, 0);
  78.            })
  79.        elseif PrimaryPart.AssemblyLinearVelocity.Magnitude < 50 or PrimaryPart.AssemblyAngularVelocity.Magnitude > 50 then
  80.            LastPosition = PrimaryPart.CFrame
  81.        end
  82.    end)
  83. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement