while wait(tweentime * (tweenbackMultiplier/2)) do
if wind then
local CFrameDifference = CFrame.Angles(math.random(-windStrengh, windStrengh), math.rad(0), math.random(-windStrengh, windStrengh)
for i, grass in ipairs(GrassFolder:GetChildren()) do
local windtween = TS:Create(grass.PrimaryPart, tweenInfoWind, {CFrame = grass.PrimaryPart.CFrame * CFrameDifference)})
windtween:Play()
if not touching then
wait(tweentime / 1.2)
local normaltween2 = TS:Create(grass.PrimaryPart, tweenInfoWind, {CFrame = grass.RotateMain.CFrame * CFrame.Angles(math.rad(math.random(-1, 1)), math.rad(0), math.rad(math.random(-1, 1)))})
normaltween2:Play()
end
end
end
end
It probably occurs because you are multiplying the current CFrame by the new âCFrameDifferenceâ that iâve put in, You will want to check that the âwindtweenâ is not called more than once, just make sure itâs not doing it over and over again (check your while wait(tweentime * (tweenbackMultiplier/2)) do)
Copy the code i sent as it is now because iâve edited it a bit, Come back to me if it still doesnât work
hey, TheHeroGamer001 I was looking at this topic and it seems very interesting. Is it possible if you could send a video of how it turned out, I want to try and implement this into my game but I donât know how it turned out so I would like to see an example first!
how did you get the wind system to work I have been trying to figure it out but I am not able to. i have no idea how you implemented it into the script
As shown here, this is how I would get the wind to work. It has been 2 years and i havenât been developing for awhile so I may not have the answer for you right away.
But the idea is that you have âwind gustsâ so at every time interval (tweentime * (tweenbackmultiplier/2)) it will apply a tween to each grasspart transforming it to move in the direction fo the wind.
Try using the quoted piece of code and if possible, DM me about this so we are not necrobumping this thread
Iâve had the same issue with grass and wanted to make one and I found that your solution is very helpful but I canât seem to know where exactly to place everything or whether if the script is local or not.
(Yes the grass mesh is quite primitive)
This is all done in a local script to compensate for the servers processing
(Meaning this does not replicate but it is very efficient)
(Layout Of grass and folder)
(Video of grass working and wind)
(RBXM (ROBLOX MODEL FILE) FILE) grasssys.rbxm (33.2 KB)
Roblox isnt lettting me stuff this into a .rbxl file for some resaon but here is the code
remember you need to add two attributes in the script these are the two attributes the script assumes that the wheels are named âWheelâ And Make sure can touch is on for the wheel
local GrassFolder = workspace.Grass
local TS = game:GetService("TweenService")
-----|| Settings ||-----
local multiplier = 28
local tweentime = .8
local cooldown_devision = 8
local tweenInfoNormal = TweenInfo.new(tweentime * 2, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local tweenInfoTouched = TweenInfo.new(tweentime)
local RandomSize = false
-----| Debounce Dictionary |-----
local CoolDown = {}
for i, grass in ipairs(GrassFolder:GetChildren()) do
grass.PrimaryPart.Transparency = 0
grass.RotateMain.Transparency = 1
if RandomSize then grass.PrimaryPart.Size = Vector3.new(math.random(2,8),grass.PrimaryPart.Size.Y,math.random(2,8)) end
grass.HitBox.Touched:Connect(function(hit:BasePart)
if hit.Parent:FindFirstChild("Humanoid") then
CoolDown[grass] = true
local hum = hit.Parent:FindFirstChild("Humanoid")
local movedir = hum.MoveDirection.Unit
if movedir.Magnitude > 0 then
local facevector = grass.RotateMain.CFrame * CFrame.Angles(math.rad(movedir.X * multiplier), math.rad(0), math.rad(movedir.Z * multiplier))
local TweenMove = TS:Create(grass.PrimaryPart, tweenInfoTouched, {CFrame = facevector})
TweenMove:Play()
task.wait(tweentime / cooldown_devision)
CoolDown[grass] = false
return end
CoolDown[grass] = false
elseif hit.Name == "Wheel" then
CoolDown[grass] = true
local movedir = hit.AssemblyLinearVelocity
if movedir.Magnitude > 0 then
local facevector = grass.RotateMain.CFrame * CFrame.Angles(math.rad(movedir.X * multiplier), math.rad(0), math.rad(movedir.Z * multiplier))
local TweenMove = TS:Create(grass.PrimaryPart, tweenInfoTouched, {CFrame = facevector})
TweenMove:Play()
task.wait(tweentime / cooldown_devision)
CoolDown[grass] = false
return end
CoolDown[grass] = false
end
end)
grass.HitBox.TouchEnded:Connect(function(hit:BasePart)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum then
local movedir = hum.MoveDirection.Unit
local facevector = grass.RotateMain.CFrame * CFrame.Angles(math.rad(0), math.rad(0), math.rad(0))
local TweenNormal = TS:Create(grass.PrimaryPart, tweenInfoNormal, {CFrame = facevector})
TweenNormal:Play()
elseif hit.Name == "Wheel" then
local movedir = hit.AssemblyLinearVelocity
local facevector = grass.RotateMain.CFrame * CFrame.Angles(math.rad(0), math.rad(0), math.rad(0))
local TweenNormal = TS:Create(grass.PrimaryPart, tweenInfoNormal, {CFrame = facevector})
TweenNormal:Play()
end
end)
end
---------------| WIND | -------------
while task.wait(0.2) do
wind = script:GetAttribute("wind")
windStrengh = script:GetAttribute("windStrengh")
if wind then
for i, grass in ipairs(GrassFolder:GetChildren()) do
local movescalar = math.random(-2,2)
local movedir = Vector3.new(math.random(1,2),math.random(1,2),math.random(1,2)).Unit
local CFrameDifference = grass.RotateMain.CFrame * CFrame.Angles(math.rad(movedir.X * multiplier), math.rad(0), math.rad(movedir.Z * multiplier))
local windtween = TS:Create(grass.PrimaryPart, tweenInfoTouched, {CFrame = CFrameDifference})
windtween:Play()
end
end
end