I’m using an BodyForce to cause air resistance when infront of an fan, but it does a lot more force whilst in the air, are there any fixes or alternatives to doing this?
local Fan = {}
Fan.__index = Fan
function Fan.new(f)
local self = setmetatable({}, Fan)
self.fan = f
self.Region = f:WaitForChild("Region")
return self
end
function Fan:Activate()
local overlapParams = OverlapParams.new()
overlapParams.FilterDescendantsInstances = {self.fan}
local playersAffected = {}
game:GetService("RunService").Heartbeat:Connect(function()
local parts = workspace:GetPartsInPart(self.Region, overlapParams)
for i, p in ipairs(parts) do
local player = game.Players:GetPlayerFromCharacter(p.Parent)
if player then
if not playersAffected[player] then
playersAffected[player] = true
local character = p.Parent
local characterRoot = character:FindFirstChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
local direction = self.fan.PrimaryPart.CFrame.RightVector
local windStrength = self.fan:GetAttribute("WindStrength")
local direciton = characterRoot.CFrame.LookVector
local resistanceForce = direction * windStrength
local bodyForce = Instance.new("BodyForce", characterRoot)
bodyForce.Force = resistanceForce
end
end
end
end)
end
return Fan