Better method Wind Resistance/Push on Characters ; Flings on Ice/low friction floormaterials, doesnt move on high friction

Hello, I am looking to solve a problem case where the player character ends up getting flung but it only occurs on low friction material; terrain ice/snow. Additionally high friction terrain just negates this system altogether.

In standard baseplate it works as expected but It seems like terrain imposes different frictions and disrupts the intention of this module. I’d really like to have have a universal mathematical resistor but I haven’t been able to make one work…

-------------------------------------------------
-- SERVICES
-------------------------------------------------

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

-- Modules
local ConveyorSystem = require(script.ConveyorSystem)

-------------------------------------------------
-- CONFIG
-------------------------------------------------

local WIND_FORCE = 8000
local MAX_SPEED = 50
local ATTACH_NAME = "WindForce"

local MIN_Y = 0
local MAX_Y = 500
local ALLOW_WIND_RESISTANCE = true

-------------------------------------------------
-- STATE
-------------------------------------------------

local windDir = Vector3.new(1, 0, 0).Unit
local WIND_ENABLED = true

-------------------------------------------------
-- API
-------------------------------------------------

local function SetWindDirection(dir: Vector3)
	if dir.Magnitude == 0 then return end
	windDir = dir.Unit
end

local function SetWindEnabled(state: boolean)
	WIND_ENABLED = state
end

-------------------------------------------------
-- UTIL
-------------------------------------------------

local function getWindForce(hrp: BasePart): VectorForce
	local force = hrp:FindFirstChild(ATTACH_NAME) :: VectorForce?
	if force then return force end

	force = Instance.new("VectorForce")
	force.Name = ATTACH_NAME

	local attachment = Instance.new("Attachment")
	attachment.Parent = hrp

	force.Attachment0 = attachment
	force.Force = Vector3.zero
	force.RelativeTo = Enum.ActuatorRelativeTo.World
	force.Parent = hrp

	return force
end

-------------------------------------------------
-- GROUND CHECK (RAYCAST + HUMANOID STATE)
-------------------------------------------------

local GROUND_CHECK_DISTANCE = 4 -- studs below HRP
local MAX_SLOPE_ANGLE = 75 -- degrees (optional safety)

local function isGrounded(hrp: BasePart, humanoid: Humanoid): boolean
	-- First: basic humanoid state filter (cheap early exit)
	local state = humanoid:GetState()
	local validState =
		state == Enum.HumanoidStateType.Running
		or state == Enum.HumanoidStateType.Landed
		or state == Enum.HumanoidStateType.RunningNoPhysics

	if not validState then
		return false
	end

	-- Raycast params (ignore character)
	local params = RaycastParams.new()
	params.FilterType = Enum.RaycastFilterType.Exclude
	params.FilterDescendantsInstances = {hrp.Parent}

	-- Cast downward
	local result = Workspace:Raycast(
		hrp.Position,
		Vector3.new(0, -GROUND_CHECK_DISTANCE, 0),
		params
	)

	if not result then
		return false -- nothing below → definitely airborne
	end

	-- Optional: slope check (prevents wall/steep detection)
	local normal = result.Normal
	local angle = math.deg(math.acos(normal:Dot(Vector3.yAxis)))

	if angle > MAX_SLOPE_ANGLE then
		return false
	end

	return true
end

local rayParams = RaycastParams.new()
rayParams.FilterDescendantsInstances = {workspace:WaitForChild("Terrain")}
rayParams.FilterType = Enum.RaycastFilterType.Include

local function isOutside(hrp: BasePart): boolean
	local result = Workspace:Raycast(hrp.Position, Vector3.new(0, 500, 0), rayParams)
	return result == nil
end

local function isValidAltitude(hrp: BasePart): boolean
	local y = hrp.Position.Y
	return y >= MIN_Y-- and y <= MAX_Y
end

-------------------------------------------------
-- CORE
-------------------------------------------------

local function applyWind(hrp: BasePart, humanoid: Humanoid)
	local force = getWindForce(hrp)

	-- Master toggle
	if not WIND_ENABLED then
		force.Force = Vector3.zero
		return
	end

	-- Environment checks
	if ALLOW_WIND_RESISTANCE then
		if not isOutside(hrp) or not isValidAltitude(hrp) then
			force.Force = Vector3.zero
			return
		end
	end

	-- Ground check
	if not isGrounded(hrp, humanoid) then
		force.Force = Vector3.zero
		return
	end

	-- Clamp horizontal velocity
	local vel = hrp.AssemblyLinearVelocity
	local horizontalVel = Vector3.new(vel.X, 0, vel.Z)

	if horizontalVel.Magnitude > MAX_SPEED then
		horizontalVel = horizontalVel.Unit * MAX_SPEED
		hrp.AssemblyLinearVelocity = Vector3.new(horizontalVel.X, vel.Y, horizontalVel.Z)
	end

	-- Apply force
	force.Force = Vector3.new(windDir.X, 0, windDir.Z) * WIND_FORCE
end

-------------------------------------------------
-- CONVEYOR MODULE
-------------------------------------------------

local WindModule = {}

function WindModule.Init(Data, dt)
	local hrp = Data.HRP
	local humanoid = Data.Humanoid

	if not hrp or not humanoid or hrp.Parent == nil then
		return false -- destroy conveyor
	end

	applyWind(hrp, humanoid)

	return true
end

-------------------------------------------------
-- CHARACTER SETUP
-------------------------------------------------

local function SetupCharacter(character: Model)
	local humanoid = character:WaitForChild("Humanoid") :: Humanoid
	local hrp = character:WaitForChild("HumanoidRootPart") :: BasePart

	local Conveyor = ConveyorSystem.new({
		ModuleScript = script,
		ModuleScriptRequired = WindModule,
		UpdateFrequency = 1, -- runs every tick (can tune to 2–4)
		Data = {
			HRP = hrp,
			Humanoid = humanoid,
		}
	})

	Conveyor.Data.Conveyor = Conveyor

	-- Cleanup on death
	humanoid.Died:Connect(function()
		Conveyor:Destroy()
	end)
end

-------------------------------------------------
-- INIT
-------------------------------------------------

-- Existing players
for _, player in Players:GetPlayers() do
	if player.Character then
		SetupCharacter(player.Character)
	end

	player.CharacterAdded:Connect(SetupCharacter)
end

-- New players
Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(SetupCharacter)
end)

-------------------------------------------------
-- EXPORT
-------------------------------------------------

return {
	SetWindDirection = SetWindDirection,
	SetWindEnabled = SetWindEnabled,
}

The issue you’re running into is that friction affects how forces apply to characters differently, and you’re fighting against Roblox’s physics engine rather than working with it.Here’s the core problem: When you apply force to a humanoid on low-friction terrain, the character accelerates freely. On high-friction terrain, friction dampens that acceleration significantly. A universal mathematical resistor won’t solve this because friction is already a built-in physics property.Better approach—use velocity clamping instead of relying on friction:lualocal humanoidRootPart = character:WaitForChild("HumanoidRootPart")local velocity = humanoidRootPart.AssemblyLinearVelocity-- Apply your wind forcehumanoidRootPart.AssemblyLinearVelocity = velocity + (windDirection * (WIND_FORCE / humanoidRootPart.AssemblyMass))-- Clamp velocity regardless of frictionlocal currentSpeed = velocity.Magnitudeif currentSpeed > MAX_SPEED then humanoidRootPart.AssemblyLinearVelocity = (velocity.Unit * MAX_SPEED)endWhy this works: You’re directly controlling the maximum velocity output rather than hoping friction will do it for you. This gives consistent behavior across all terrain types.Alternative—detect terrain friction and scale force:lualocal terrain = Workspace.Terrainlocal material, size = terrain:FindPartOnRay(Ray.new(humanoidRootPart.Position, Vector3.new(0, -5, 0)))local frictionMultiplier = (material == Enum.Material.Ice) and 1.2 or 0.8-- Then apply: WIND_FORCE * frictionMultiplierThe second approach is more complex but gives you finer control. I’d recommend the first method—it’s simpler and more predictable.Also, verify you’re using AssemblyLinearVelocity instead of Velocity; the latter can behave inconsistently with humanoids.

I got a reasonable solution but I’m sure theres a better methodology. feel free to use as a reference point

--!strict

-------------------------------------------------
-- SERVICES
-------------------------------------------------

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

-------------------------------------------------
-- PLAYER
-------------------------------------------------

local LocalPlayer = Players.LocalPlayer

-------------------------------------------------
-- CONFIG
-------------------------------------------------

local WIND_FORCE = 8500
local MAX_SPEED = 25

local MIN_Y = 0
local ALLOW_WIND_RESISTANCE = true

local GROUND_CHECK_DISTANCE = 4
local MAX_SLOPE_ANGLE = 75

-------------------------------------------------
-- STATE
-------------------------------------------------

local windDir = Vector3.new(1, 0, 0).Unit
local WIND_ENABLED = true

-------------------------------------------------
-- MATERIAL FRICTION (only what we need)
-------------------------------------------------

local MATERIAL_FRICTION = {
	[Enum.Material.Ice] = 0.02,
	[Enum.Material.Glacier] = 0.05,
}

local DEFAULT_FRICTION = 0.5

-------------------------------------------------
-- API
-------------------------------------------------

local function SetWindDirection(dir: Vector3)
	if dir.Magnitude == 0 then return end
	windDir = dir.Unit
end

local function SetWindEnabled(state: boolean)
	WIND_ENABLED = state
end

-------------------------------------------------
-- RAYCAST PARAMS
-------------------------------------------------

local groundParams = RaycastParams.new()
groundParams.FilterType = Enum.RaycastFilterType.Exclude

local outsideParams = RaycastParams.new()
outsideParams.FilterType = Enum.RaycastFilterType.Include
outsideParams.FilterDescendantsInstances = {Workspace:WaitForChild("Terrain")}

-------------------------------------------------
-- CHECKS
-------------------------------------------------

local function isGrounded(hrp: BasePart, humanoid: Humanoid): (boolean, Enum.Material?)
	local state = humanoid:GetState()

	local validState =
		state == Enum.HumanoidStateType.Running
		or state == Enum.HumanoidStateType.Landed
		or state == Enum.HumanoidStateType.RunningNoPhysics

	if not validState then
		return false, nil
	end

	groundParams.FilterDescendantsInstances = {hrp.Parent}

	local result = Workspace:Raycast(
		hrp.Position,
		Vector3.new(0, -GROUND_CHECK_DISTANCE, 0),
		groundParams
	)

	if not result then
		return false, nil
	end

	local normal = result.Normal
	local angle = math.deg(math.acos(normal:Dot(Vector3.yAxis)))

	if angle > MAX_SLOPE_ANGLE then
		return false, nil
	end

	return true, result.Material
end

local function isOutside(hrp: BasePart): boolean
	local result = Workspace:Raycast(
		hrp.Position,
		Vector3.new(0, 500, 0),
		outsideParams
	)
	return result == nil
end

local function isValidAltitude(hrp: BasePart): boolean
	return hrp.Position.Y >= MIN_Y
end

-------------------------------------------------
-- CORE WIND (WITH DRAG FIX)
-------------------------------------------------

local function applyWind(hrp: BasePart, humanoid: Humanoid, dt: number)
	if not WIND_ENABLED then return end

	if ALLOW_WIND_RESISTANCE then
		if not isOutside(hrp) or not isValidAltitude(hrp) then
			return
		end
	end

	local grounded, material = isGrounded(hrp, humanoid)
	if not grounded then return end

	local vel = hrp.AssemblyLinearVelocity
	local horizontalVel = Vector3.new(vel.X, 0, vel.Z)

	-------------------------------------------------
	-- APPLY WIND (UNCHANGED)
	-------------------------------------------------

	local acceleration = (windDir * (WIND_FORCE / hrp.AssemblyMass))
	local friction = MATERIAL_FRICTION[material or Enum.Material.Air] or DEFAULT_FRICTION
	acceleration *= math.clamp(friction / 0.3, 0.55, 1)
	horizontalVel += Vector3.new(acceleration.X, 0, acceleration.Z) * dt

	-------------------------------------------------
	-- DRAG (THE ACTUAL FIX)
	-------------------------------------------------

	
	-- Normalize (0 → 1)
	local norm = math.clamp(friction / 1.5, 0, 1)

	-- Convert to drag factor
	-- Ice → strong drag, Normal → light drag
	local drag = 1 - (0.02 + (1 - norm) * 0.08)

	horizontalVel *= drag

	-------------------------------------------------
	-- CLAMP
	-------------------------------------------------

	if horizontalVel.Magnitude > MAX_SPEED then
		horizontalVel = horizontalVel.Unit * MAX_SPEED
	end

	hrp.AssemblyLinearVelocity = Vector3.new(
		horizontalVel.X,
		vel.Y,
		horizontalVel.Z
	)
end

-------------------------------------------------
-- CHARACTER
-------------------------------------------------

local currentConnection: RBXScriptConnection? = nil

local function SetupCharacter(character: Model)
	if currentConnection then
		currentConnection:Disconnect()
	end

	local humanoid = character:WaitForChild("Humanoid") :: Humanoid
	local hrp = character:WaitForChild("HumanoidRootPart") :: BasePart

	currentConnection = RunService.Heartbeat:Connect(function(dt)
		if not character.Parent then return end
		applyWind(hrp, humanoid, dt)
	end)
end

-------------------------------------------------
-- INIT
-------------------------------------------------

if LocalPlayer.Character then
	SetupCharacter(LocalPlayer.Character)
end

LocalPlayer.CharacterAdded:Connect(SetupCharacter)

return {
	SetWindDirection = SetWindDirection,
	SetWindEnabled = SetWindEnabled,
}