Fling prevention

Hi, I just wanted to share this simple way to prevent flinging without entirely disabling player collisions.

I hope someone finds this useful.

This is a client sided script.

local RunService = game:GetService("RunService")
local Players = game:GetService("Players")


RunService.PreSimulation:Connect(function()
	for _, player in Players:GetPlayers() do
		if player == Players.LocalPlayer then
			continue
		end
		
		local character = player.Character
		if character == nil then
			continue
		end
		local rootPart = character.PrimaryPart
		if rootPart == nil then
			continue
		end
		
		local angularVelocity = rootPart.AssemblyAngularVelocity
		local linearVelocity = rootPart.AssemblyLinearVelocity
		
		
		
		if vector.magnitude(linearVelocity) > 50 or vector.magnitude(angularVelocity) > 50 then
			for _, child in character:GetChildren() do
				if child:IsA("BasePart") then
					child.CanCollide = false
				end
			end
		end
	end
end)

It works by disabling collisions for players that are going too fast over a certain treshold locally. Humanoid automatically re-enables them after.

3 Likes

Setting the velocity to 0 also works, but I found that disabling collisions entirely works best. Choose whichever method fits your project best (or use another approach to prevent velocity transfer between two physics objects, such as collision groups).

1 Like

Can I ask why, for a client-sided script, you are running the calculations for every player except the client running the code?

3 Likes

The player is protecting themselves from other players. It sounds janky but it works wonderful

4 Likes