I believe you can move the plant model to a desired position when either a player’s distance from it is really close[meaning he’s walking into it], and if he actually reached distance 0, you could make the plant move aside or something.
thanks! that’s a good idea, can you show me a code for that because I have tried that but I don’t think I did the code right. I tried basing it off this other persons topic but i could not get it to work
so I was thinking and I decided to put all the plants in a folder, so I rewrote the script to make it work for all plants. The issue is that that doesn’t even work I set it to move the primary part but it won’t work. Btw I fixed the line 15 issue I had to put 0.5 in the TweenInfo spot
local grassfolder = workspace.Grass
local ts = game:GetService(“TweenService”)
while wait(.1) do
for i, grass in pairs(grassfolder:GetChildren()) do
grass.HitBox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local hum = hit.Parent:FindFirstChild("Humanoid")
local movedir = hum.MoveDirection.Unit
print(movedir.X, movedir.Z)
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
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