Wind values change but grass doesn't get effected?

  1. What do you want to achieve? Keep it simple and clear!
    I’m trying to make wind change via a script. Simple.

  2. What is the issue? Include screenshots / videos if possible!
    Grass doesn’t get effected by the wind change.

  3. 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.

Server Script:

---- Variables ----
--Wind
local GlobalWind = game.Workspace.GlobalWind
local OriginalWind = Vector3.new(25, 0, 50)
local InfluencedWind = Vector3.new(200, 0, 500)

--Remote Events
local StartWindEvent = game.ReplicatedStorage.StartWind


---- Code ----
print("1")
GlobalWind = OriginalWind
print(GlobalWind)

StartWindEvent.Event:Connect(function()
	print("2")
	GlobalWind = InfluencedWind
	print(GlobalWind)
	wait(5)
	print("3")
	GlobalWind = OriginalWind
	print(GlobalWind)
end)

The outputs prints:
1
25, 0, 50
2
200, 0, 500
3
25, 0, 50

GlobalWind is not a path to the property, but a copy of the original value, saved in a variable.

workspace.GlobalWind = Vector3.new(200, 0, 500)

Analogous case:

print(workspace.NumberValue.Value) --> 5
local numberValue = workspace.NumberValue.Value
print(numberValue) --> 5 (not value base)
1 Like

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)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.