Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- G.AntiFlingConfig = {
- -- this will remove your rotational velocity every frame
- disable_rotation = true;
- -- this slows you down if you're moving too fast, works well but can give you a low gravity effect
- limit_velocity = true;
- limit_velocity_sensitivity = 150; -- how fast you have to be moving before you get slowed down
- limit_velocity_slow = 0; -- the amount of velocity you keep; a lower number increases how much you slow down by
- -- stops you from ragdolling or falling over and losing control
- anti_ragdoll = true;
- -- completely freezes you if someone gets too close to you
- anchor = false;
- smart_anchor = true; -- only anchors if someone is considered flinging, this likely won't detect many flings
- anchor_dist = 30; -- how close someone has to be to trigger anchor
- -- teleport away if someone gets too close
- teleport = false;
- smart_teleport = true; -- only teleports if someone is considered flinging, this likely won't detect many flings
- teleport_dist = 30; -- how close someone has to be to teleport you
- }
- -- run _G.disable() to disable the script completely
- local Players = Game:GetService"Players"
- local plr = Players.LocalPlayer
- local function Enable()
- for i,v in pairs (Players:GetPlayers()) do
- Collide(v)
- end
- end
- function G:Enable()
- C = game:GetService"RunService".RenderStepped: Connect (Enable)
- end
- function G:Disable()
- C: Disconnect ()
- for i,v in pairs(game.Players:GetPlayers()) do
- if v ~= plr then
- for h,b in pairs(v.Character:GetDescendants()) do
- if b:IsA"BasePart" and b.CanCollide == false then
- b.CanCollide = true
- end
- end
- end
- end
- end
- G:Enable()
- return G
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local function getCharacterComponents(character)
- local humanoidRootPart = character:FindFirstChild("HumanoidRootPart") or character:FindFirstChild("Torso") or character:FindFirstChild("UpperTorso")
- local humanoid = character:FindFirstChild("Humanoid")
- return humanoidRootPart, humanoid
- end
- local function applyAntiFling(humanoidRootPart, lastSafePosition)
- local antiFlingBP = Instance.new("BodyPosition", humanoidRootPart)
- antiFlingBP.Position = lastSafePosition
- antiFlingBP.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
- antiFlingBP.P = 10000
- wait(0.1) -- Adjust the duration to control how long the character stays in place
- antiFlingBP:Destroy()
- humanoidRootPart.CFrame = CFrame.new(lastSafePosition)
- end
- local function antiFling()
- local localPlayer = Players.LocalPlayer
- local maxVelocityChange = 50 -- Set a maximum allowed change in velocity to detect flinging
- local lastVelocity = Vector3.new(0, 0, 0)
- local lastSafePosition = Vector3.new(0, 5, 0)
- while true do
- RunService.Heartbeat:Wait()
- local character = localPlayer.Character
- local humanoidRootPart, humanoid = getCharacterComponents(character)
- if humanoidRootPart and humanoid then
- local currentVelocity = humanoidRootPart.Velocity
- local velocityChange = (currentVelocity - lastVelocity).Magnitude
- if velocityChange > maxVelocityChange then
- applyAntiFling(humanoidRootPart, lastSafePosition)
- else
- lastSafePosition = humanoidRootPart.Position
- end
- lastVelocity = currentVelocity
- end
- end
- end
- antiFling()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement