Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- // Constants \\ --
- -- [ Services ] --
- local Services = setmetatable({}, {__index = function(Self, Index)
- local NewService = game.GetService(game, Index)
- if NewService then
- Self[Index] = NewService
- end
- return NewService
- end})
- -- [ LocalPlayer ] --
- local LocalPlayer = Services.Players.LocalPlayer
- -- // Functions \\ --
- local function PlayerAdded(Player)
- local Detected = false
- local Character;
- local PrimaryPart;
- local function CharacterAdded(NewCharacter)
- Character = NewCharacter
- repeat
- wait()
- PrimaryPart = NewCharacter:FindFirstChild("HumanoidRootPart")
- until PrimaryPart
- Detected = false
- end
- CharacterAdded(Player.Character or Player.CharacterAdded:Wait())
- Player.CharacterAdded:Connect(CharacterAdded)
- Services.RunService.Heartbeat:Connect(function()
- if (Character and Character:IsDescendantOf(workspace)) and (PrimaryPart and PrimaryPart:IsDescendantOf(Character)) then
- if PrimaryPart.AssemblyAngularVelocity.Magnitude > 50 or PrimaryPart.AssemblyLinearVelocity.Magnitude > 100 then
- if Detected == false then
- game.StarterGui:SetCore("ChatMakeSystemMessage", {
- Text = "Fling Exploit detected, Player: " .. tostring(Player);
- Color = Color3.fromRGB(255, 200, 0);
- })
- end
- Detected = true
- for i,v in ipairs(Character:GetDescendants()) do
- if v:IsA("BasePart") then
- v.CanCollide = false
- v.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
- v.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
- v.CustomPhysicalProperties = PhysicalProperties.new(0, 0, 0)
- end
- end
- PrimaryPart.CanCollide = false
- PrimaryPart.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
- PrimaryPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
- PrimaryPart.CustomPhysicalProperties = PhysicalProperties.new(0, 0, 0)
- end
- end
- end)
- end
- -- // Event Listeners \\ --
- for i,v in ipairs(Services.Players:GetPlayers()) do
- if v ~= LocalPlayer then
- PlayerAdded(v)
- end
- end
- Services.Players.PlayerAdded:Connect(PlayerAdded)
- local LastPosition = nil
- Services.RunService.Heartbeat:Connect(function()
- pcall(function()
- local PrimaryPart = LocalPlayer.Character.PrimaryPart
- if PrimaryPart.AssemblyLinearVelocity.Magnitude > 250 or PrimaryPart.AssemblyAngularVelocity.Magnitude > 250 then
- PrimaryPart.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
- PrimaryPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
- PrimaryPart.CFrame = LastPosition
- game.StarterGui:SetCore("ChatMakeSystemMessage", {
- Text = "You were flung. Neutralizing velocity.";
- Color = Color3.fromRGB(255, 0, 0);
- })
- elseif PrimaryPart.AssemblyLinearVelocity.Magnitude < 50 or PrimaryPart.AssemblyAngularVelocity.Magnitude > 50 then
- LastPosition = PrimaryPart.CFrame
- end
- end)
- end)
- 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()
- end)
- _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 ccompletel
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement