Advertisement
C-H-4-0-S

Antifling v3

Jul 27th, 2024
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.14 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)
  84.  
  85.  
  86. local Players = game:GetService("Players")
  87. local RunService = game:GetService("RunService")
  88.  
  89. local function getCharacterComponents(character)
  90. local humanoidRootPart = character:FindFirstChild("HumanoidRootPart") or character:FindFirstChild("Torso") or character:FindFirstChild("UpperTorso")
  91. local humanoid = character:FindFirstChild("Humanoid")
  92. return humanoidRootPart, humanoid
  93. end
  94.  
  95. local function applyAntiFling(humanoidRootPart, lastSafePosition)
  96. local antiFlingBP = Instance.new("BodyPosition", humanoidRootPart)
  97. antiFlingBP.Position = lastSafePosition
  98. antiFlingBP.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  99. antiFlingBP.P = 10000
  100.  
  101. wait(0.1) -- Adjust the duration to control how long the character stays in place
  102.  
  103. antiFlingBP:Destroy()
  104. humanoidRootPart.CFrame = CFrame.new(lastSafePosition)
  105. end
  106.  
  107. local function antiFling()
  108. local localPlayer = Players.LocalPlayer
  109. local maxVelocityChange = 50 -- Set a maximum allowed change in velocity to detect flinging
  110.  
  111. local lastVelocity = Vector3.new(0, 0, 0)
  112. local lastSafePosition = Vector3.new(0, 5, 0)
  113.  
  114. while true do
  115. RunService.Heartbeat:Wait()
  116. local character = localPlayer.Character
  117. local humanoidRootPart, humanoid = getCharacterComponents(character)
  118.  
  119. if humanoidRootPart and humanoid then
  120. local currentVelocity = humanoidRootPart.Velocity
  121. local velocityChange = (currentVelocity - lastVelocity).Magnitude
  122.  
  123. if velocityChange > maxVelocityChange then
  124. applyAntiFling(humanoidRootPart, lastSafePosition)
  125. else
  126. lastSafePosition = humanoidRootPart.Position
  127. end
  128.  
  129. lastVelocity = currentVelocity
  130. end
  131. end
  132. end
  133.  
  134. antiFling()
  135. end)
  136. _G.AntiFlingConfig = {
  137. -- this will remove your rotational velocity every frame
  138. disable_rotation = true;
  139.  
  140. -- this slows you down if you're moving too fast, works well but can give you a low gravity effect
  141. limit_velocity = true;
  142. limit_velocity_sensitivity = 150; -- how fast you have to be moving before you get slowed down
  143. limit_velocity_slow = 0; -- the amount of velocity you keep; a lower number increases how much you slow down by
  144.  
  145. -- stops you from ragdolling or falling over and losing control
  146. anti_ragdoll = true;
  147.  
  148. -- completely freezes you if someone gets too close to you
  149. anchor = false;
  150. smart_anchor = true; -- only anchors if someone is considered flinging, this likely won't detect many flings
  151. anchor_dist = 30; -- how close someone has to be to trigger anchor
  152.  
  153. -- teleport away if someone gets too close
  154. teleport = false;
  155. smart_teleport = true; -- only teleports if someone is considered flinging, this likely won't detect many flings
  156. teleport_dist = 30; -- how close someone has to be to teleport you
  157. }
  158. -- run _G.disable() to disable the script ccompletel
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement