How would I go about making Interactive plants/grass

You are connecting the same Touched events every 1/10 of a second. This is very inefficient code.

Is every grass a model?

yes they are models. but the grass model has like 20 stands from grass in it

this is the grass model

You can’t tween models just by tweening the primarypart there is something else to do.

Here is a method:

local tweenService = game:GetService("TweenService")
local info = TweenInfo.new()

local function tweenModel(model, CF)
	local CFrameValue = Instance.new("CFrameValue")
	CFrameValue.Value = model:GetPivot()

	CFrameValue:GetPropertyChangedSignal("Value"):connect(function()
		model:PivotTo(CFrameValue.Value)
	end)
	
	local tween = tweenService:Create(CFrameValue, info, {Value = CF})
	tween:Play()
	
	tween.Completed:connect(function()
		CFrameValue:Destroy()
	end)
end
2 Likes

ok, i will try it, but how would i test this do i just put this in the model or?

tweenModel(grassModel, tweenInfo, CFrame)

wait but that would not work there is no touched event

It’s a METHOD to tween the model… You put it in the touched event.

ooh ok, thanks! sorry sometimes my brain doesn’t process things lol

I don’t know why but i am really struggling to figure this out, everything I try to do to make it work doesn’t work I don’t know what I am doing wrong. The whole script is a mess now lol

hey! so I have been trying to use this guy’s script to try and implement it into mine because I have no other idea on how to do it myself. I was wondering if you could walk me through the script so i could understand it better and maybe try using it to make my plants shake. I found this guys when searching and he is trying to do the same thing as me

i want to try and understand this version of the script

local grassfolder = workspace.Grass
local Players = game:GetService(‘Players’)
local ts = game:GetService(“TweenService”)

for i, grass in pairs(grassfolder:GetChildren()) do
local CharModel = hit:FindFirstAncestorWhichIsA(‘Accesory’)

	grass.HitBox.Touched:Connect(function(hit)
		if Players:GetPlayerFromCharacter(CharModel) then
			
			local hum = CharModel:FindFirstChild("Humanoid")
			local movedir = hum.MoveDirection.Unit
			local facevector = grass.PrimaryPart.CFrame * CFrame.Angles(math.rad(movedir.X), math.rad(0), math.rad(movedir.Z))

			local tween = ts:Create(grass.PrimaryPart, TweenInfo(.5), {CFrame = grass.PrimaryPart.CFrame * CFrame.Angles(math.rad(movedir.X), math.rad(0), math.rad(movedir.Y))})
			
			tween:Play()
			
		end
	end)
end

To make plants tween in the direction the player is walking, you will need to use some scripting. You will need to create a script that will detect the player’s direction and then use a tweening library to move the plants in the same direction.

The code would look something like this:

// Get the player’s direction
Vector2 direction = playerObject.transform.position - transform.position;

// Move the plants in the same direction
transform.position = Vector2.Lerp(transform.position, transform.position + direction, Time.deltaTime);