I got bored, so i made a random wind direction generator that has settings in the script. The script includes the possibility of storm type winds to happen.
If you wish to turn off storm winds, but do not know how to edit scripts, just change the chance value below 1, or change stormMultiFactor to 1
Heres the script, anyone can use if free of charge without credit required.
(Put it in ServerScriptService if you wish for it to be Server Side)
(Put it in StarterPlayerScripts if you wish for it to be Client Side Only)
--MADE BY: Playanad/LumberdFox/Destroyanad (I go by all of those names)
--Put This In Server Script Service
--Services
local TS = game:GetService("TweenService")
--Wind Variables
local wind = workspace.GlobalWind
local windXRange = 20 --Turn this, and the Z range up to generate higher speeds.
local windYRange = 10 --I recommend not turning this up too high
local windZRange = 20 --Turn this, and the X range up to generate higher speeds.
local stormMultiFactor = 5 --How much to multiply wind speeds during storms.
local stormChance = 10 -- 1-100 range. 10 would be a 10% chance.
while true do
local smoothTime = math.random(30,120)
local stormNum = math.random(1,100)
local nonStormMulti = 1
local windMultiplier = stormNum > stormChance and nonStormMulti or stormMultiFactor
local randomWindX = math.random(-windXRange, windXRange)
local randomWindY = math.random(-windYRange, windYRange)
local randomWindZ = math.random(-windZRange, windZRange)
if randomWindX < (windXRange / 2) then
randomWindX = math.random(-windXRange, windXRange)
end
if randomWindY < (windYRange / 2) then
randomWindY = math.random(-windYRange, windYRange)
end
if randomWindZ < (windZRange / 2) then
randomWindZ = math.random(-windZRange, windZRange)
end
local randomWindVector3 = Vector3.new(randomWindX * windMultiplier, randomWindY * (windMultiplier / 3), randomWindZ * windMultiplier)
local windTween = TS:Create(workspace, TweenInfo.new(smoothTime, Enum.EasingStyle.Linear), {GlobalWind = randomWindVector3})
windTween:Play()
task.wait(smoothTime)
end
Looks cool. Is there a way I can make a downdraft from a part that affects the grass? I have a helicopter game, and I want the terrain grass to bend from wind gusts from the propellars when the helicopter is near to the ground.
I don’t think there is a way to effect certain areas of grass. Currently any effect to grass is universal across your entire game.
You might be able to change the wind speed and direction client side so it looks like it from the pilot since they likely wont notice the entire game’s grass is moving, but it will not replicate to other player’s screens.
If you absolutely need it to replicate for other people, you could change it client side for anyone close enough to the helicopter.
I guess I could also use the gust system that roblox provides, and pair it with the helicopter rotors, something like this:
local gustCycleDelay = 5 -- Max duration between gust cycles in seconds
local gustCycleDuration = 3.5 -- Duration of each gust cycle in seconds
-- During each gust cycle, a portion of "gust" will be added to "baseWind" in a ramped fashion
local baseWind = Vector3.new(5, 0, 2) -- Base wind speed and direction
local gust = Vector3.new(25, 0, 10) -- Gust speed and direction
local gustIntervals = 100 -- Number of iterations used to calculate each gust interval
local dg = gustCycleDuration / gustIntervals
local dgf = dg / gustCycleDuration
-- Set global wind to base wind initially
workspace.GlobalWind = baseWind
-- Wait delay amount before starting gusts
task.wait(gustCycleDelay)
while true do
local rotor = workspace:FindFirstChild("Rotor") -- Find the rotor in the workspace
if rotor and rotor.Position.Y <= 20 then -- Check if rotor exists and is within 20 studs from the ground
for i = 1, gustIntervals do
local f = math.sin(math.pi * dgf * i) -- Use sin() function to ramp gust
workspace.GlobalWind = baseWind + f * gust -- Set global wind to base wind + gust
task.wait(dg)
end
workspace.GlobalWind = baseWind -- Reset global wind to base wind at end of gust cycle
end
task.wait(math.random() * gustCycleDelay) -- Wait a random fraction of delay before next gust cycle
end
You could fire an event to modify clientside GlobalWind in a getPartsInPart() function on the server. Adding parts would be done in a modulescript and for each part you add there would be a getPartsInPart() fired every so often.
Obviously not to create lag you would destroy the part when not needed and remove it from the module
This would allow for a more modularized Globalwind meaning you can add this to create extreme punch effects (Caped Baldy) and such. Idk if it would work though just something I whipped up on a whim.