Also here is the code (sorry if its messy)
Server (movement):
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)
-----| Debounce Dictionary |-----
local CoolDown = {}
local RS = game:GetService("ReplicatedStorage")
local CoolDowns = RS:WaitForChild("Grass")
CoolDowns.OnServerInvoke = function(Player)
return CoolDown
end
for i, grass in ipairs(GrassFolder:GetChildren()) do
grass.HitBox.Touched:Connect(function(hit:BasePart)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Humanoid.Sit == false 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(math.clamp(movedir.X * multiplier, -180, 180)), 0, math.rad(math.clamp(movedir.Z * multiplier, -180, 180)))
local TweenMove = TS:Create(grass, 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(math.clamp(movedir.X * multiplier, -180, 180)), 0, math.rad(math.clamp(movedir.Z * multiplier, -180, 180)))
local TweenMove = TS:Create(grass, tweenInfoTouched, {CFrame = facevector})
TweenMove:Play()
task.wait(tweentime / cooldown_devision)
CoolDown[grass] = false
return
end
--]]
elseif hit:GetAttribute("grass") then
CoolDown[grass] = true
local movedir = hit.AssemblyLinearVelocity.Unit * multiplier
-- Calculate the yaw angle based on the car's movement direction
local radians = math.atan2(movedir.Z, movedir.X)
local yaw = math.deg(radians) + 180
-- Create the new CFrame with a 20-degree lean and direction of the car's movement
local facevector = grass.RotateMain.CFrame * CFrame.Angles(math.rad(20), math.rad(yaw), 0)
local TweenMove = TS:Create(grass, tweenInfoTouched, {CFrame = facevector})
TweenMove:Play()
task.wait(tweentime / cooldown_devision)
CoolDown[grass] = false
return
end
end)
grass.HitBox.TouchEnded:Connect(function(hit:BasePart)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum and hit.Parent.Humanoid.Sit == false then
local facevector = grass.RotateMain.CFrame * CFrame.Angles(0, 0, 0)
local TweenNormal = TS:Create(grass, tweenInfoNormal, {CFrame = facevector})
TweenNormal:Play()
--[[
elseif hit.Name == "Wheel" then
local facevector = grass.RotateMain.CFrame * CFrame.Angles(0, 0, 0)
local TweenNormal = TS:Create(grass, tweenInfoNormal, {CFrame = facevector})
TweenNormal:Play()
--]]
elseif hit:GetAttribute("grass") then
local facevector = grass.RotateMain.CFrame * CFrame.Angles(0, 0, 0)
local TweenNormal = TS:Create(grass, tweenInfoNormal, {CFrame = facevector})
TweenNormal:Play()
return
end
end)
end
Client (wind):
local RS = game:GetService("ReplicatedStorage") --
local CoolDowns = RS:WaitForChild("Grass")
local TweenService = game:GetService("TweenService")
local tweenInfoTouched = TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
local GrassFolder = workspace.Grass
while wait(0.2) do
local wind = game.Workspace.GlobalWind
local windStrength = wind.Magnitude
if windStrength > 0 then
for i, grass in ipairs(GrassFolder:GetChildren()) do
local d = 1
if d < 50 then -------------------- CHANGE TO PLAYER SETTINGS (ignore)
local direction = wind.Unit
local radians = math.atan2(direction.Z, direction.X)
local yaw = math.deg(radians) + 180
local random = Random.new()
local final = windStrength / 20
local x = random:NextNumber(2, 3) + final
local z = random:NextNumber(2, 3) + final
local movedir = Vector3.new(x, yaw, z)
local CFrameDifference = grass.RotateMain.CFrame * CFrame.Angles(math.rad(movedir.X), math.rad(yaw), math.rad(movedir.Z))
local windtween = TweenService:Create(grass, tweenInfoTouched, {CFrame = CFrameDifference})
windtween:Play()
end
end
end
end