What do you want to achieve? Keep it simple and clear!
I’m trying to make wind change via a script. Simple.
What is the issue? Include screenshots / videos if possible!
Grass doesn’t get effected by the wind change.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried changing the values to extremes and lengthening the duration that it stays that way.
So how would I change the value like this code does it;
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
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
task.wait(math.random() * gustCycleDelay) -- Wait a random fraction of delay before next gust cycle
end
The above code works (From documentation) while mine doesn’t. Why? (After changing the value to workspace.GlobalWind instead of game.Workspace.GlobalWind)
workspace is just a global variable for game:GetService("Workspace"). Saving workspace.GlobalWind to a variable does not save the path, but rather the value. If the value is changed, solely the variable is, not the property of workspace.
local OriginalWind = Vector3.new(25, 0, 50)
local InfluencedWind = Vector3.new(200, 0, 500)
local StartWindEvent = game.ReplicatedStorage.StartWind
workspace.GlobalWind = OriginalWind
StartWindEvent.Event:Connect(function()
workspace.GlobalWind = InfluencedWind
task.wait(5)
workspace.GlobalWind = OriginalWind
end)