Advertisement
C-H-4-0-S

Antifling half part

May 1st, 2024
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. G.AntiFlingConfig = {
  2. -- this will remove your rotational velocity every frame
  3. disable_rotation = true;
  4.  
  5. -- this slows you down if you're moving too fast, works well but can give you a low gravity effect
  6. limit_velocity = true;
  7. limit_velocity_sensitivity = 150; -- how fast you have to be moving before you get slowed down
  8. limit_velocity_slow = 0; -- the amount of velocity you keep; a lower number increases how much you slow down by
  9.  
  10. -- stops you from ragdolling or falling over and losing control
  11. anti_ragdoll = true;
  12.  
  13. -- completely freezes you if someone gets too close to you
  14. anchor = false;
  15. smart_anchor = true; -- only anchors if someone is considered flinging, this likely won't detect many flings
  16. anchor_dist = 30; -- how close someone has to be to trigger anchor
  17.  
  18. -- teleport away if someone gets too close
  19. teleport = false;
  20. smart_teleport = true; -- only teleports if someone is considered flinging, this likely won't detect many flings
  21. teleport_dist = 30; -- how close someone has to be to teleport you
  22. }
  23. -- run _G.disable() to disable the script completely
  24.  
  25.  
  26. local Players = Game:GetService"Players"
  27. local plr = Players.LocalPlayer
  28.  
  29. local function Enable()
  30. for i,v in pairs (Players:GetPlayers()) do
  31. Collide(v)
  32. end
  33. end
  34.  
  35.  
  36.  
  37. function G:Enable()
  38. C = game:GetService"RunService".RenderStepped: Connect (Enable)
  39. end
  40. function G:Disable()
  41. C: Disconnect ()
  42. for i,v in pairs(game.Players:GetPlayers()) do
  43. if v ~= plr then
  44. for h,b in pairs(v.Character:GetDescendants()) do
  45. if b:IsA"BasePart" and b.CanCollide == false then
  46. b.CanCollide = true
  47. end
  48. end
  49. end
  50. end
  51. end
  52.  
  53. G:Enable()
  54. return G
  55.  
  56.  
  57.  
  58.  
  59. local Players = game:GetService("Players")
  60. local RunService = game:GetService("RunService")
  61.  
  62. local function getCharacterComponents(character)
  63. local humanoidRootPart = character:FindFirstChild("HumanoidRootPart") or character:FindFirstChild("Torso") or character:FindFirstChild("UpperTorso")
  64. local humanoid = character:FindFirstChild("Humanoid")
  65. return humanoidRootPart, humanoid
  66. end
  67.  
  68. local function applyAntiFling(humanoidRootPart, lastSafePosition)
  69. local antiFlingBP = Instance.new("BodyPosition", humanoidRootPart)
  70. antiFlingBP.Position = lastSafePosition
  71. antiFlingBP.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  72. antiFlingBP.P = 10000
  73.  
  74. wait(0.1) -- Adjust the duration to control how long the character stays in place
  75.  
  76. antiFlingBP:Destroy()
  77. humanoidRootPart.CFrame = CFrame.new(lastSafePosition)
  78. end
  79.  
  80. local function antiFling()
  81. local localPlayer = Players.LocalPlayer
  82. local maxVelocityChange = 50 -- Set a maximum allowed change in velocity to detect flinging
  83.  
  84. local lastVelocity = Vector3.new(0, 0, 0)
  85. local lastSafePosition = Vector3.new(0, 5, 0)
  86.  
  87. while true do
  88. RunService.Heartbeat:Wait()
  89. local character = localPlayer.Character
  90. local humanoidRootPart, humanoid = getCharacterComponents(character)
  91.  
  92. if humanoidRootPart and humanoid then
  93. local currentVelocity = humanoidRootPart.Velocity
  94. local velocityChange = (currentVelocity - lastVelocity).Magnitude
  95.  
  96. if velocityChange > maxVelocityChange then
  97. applyAntiFling(humanoidRootPart, lastSafePosition)
  98. else
  99. lastSafePosition = humanoidRootPart.Position
  100. end
  101.  
  102. lastVelocity = currentVelocity
  103. end
  104. end
  105. end
  106.  
  107. antiFling()
  108.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement