Wind Module | Make your parts affected by wind

Simple module that makes your parts move from workspace.GlobalWind
I literally spent around 5-10 minutes creating it, dont expect it to be hard.

Preview:

Module
local parts = {}
local mod = {}

function mod:AddPart(part:Instance, multiplier:number)
	if not parts[part] then
		parts[part] = (typeof(multiplier) == 'number' and multiplier) or 1
	end
end

function mod:RemovePart(part:Instance)
	if parts[part] then
		parts[part] = nil
	else
		return false
	end
end

function mod:GetAffectedParts()
	return parts
end

game:GetService('RunService').Heartbeat:Connect(function(dt)
	for i, v in pairs(parts) do
		if i then
			i.Velocity += workspace.GlobalWind*dt*v
		end
	end
end)

return mod

Usage:

  1. Init the module local wind = require(Path_To_Module)

  2. Functions:
    wind:AddPart(<BasePart>, <Force Multiplier | defaults to 1>) Makes part move
    wind:RemovePart(<BasePart>) Does the opposite
    wind:GetAffectedParts() Returns a list of every affected part, looks like:

{
	[<BasePart>] = <Multiplier>
}
  1. The end?
40 Likes

Will defo use this very lovely script

6 Likes

Damn, I didn’t expect someone to actually make parts be affected by wind like I wanted :joy:

Great job on that, I’ll try using it for my upcoming game.

6 Likes

I was thinking about making something like this too, great job!
Also you should make this into a model that people can grab & you can update if you choose to add more features later down the line.
Thanks for this cool resource

This module was planned as a quick project, I simply dont know what to add. Drop me suggestions and I will try my best :smile:

Finally we have O2! Thanks for this!

I would 100% use it on my game, because I want my trees to be able to move by wind

1 Like

Maybe try adding Model / Character support? (if its not there already)

What?

Just do V3 * mul.

thirtycharacters

2 Likes

V3 is velocity and mul is number. Vector3 value and number can’t be multiplied.

Overworked with CFrages, forgot its possible. Fixed.

You can.

Multiplying Vector3.new(2,2,2) with 5 gives you Vector3.new(10,10,10)

Never knew that, sorry. Good to know something new.

Simply use the module on HumanoidRootPart, preferably on client. Models can get moved by a primary part and welds.

1 Like

how can i make my trees wiggle with the wind?

2 Likes