Tower defense zombie going inside path?

i am making a small tower defense game, and i just finished the zombie movement, it works perfectly fine, but there is one thing that triggers me, the zombie goes inside the path, it is very subtle, but then you when it reaches it’s current node, it just slightly goes up, unfortunately, i cannot send a vid but i can show you a model: path thingy - Roblox

script:

local root = script.Parent.HumanoidRootPart

local path = game.Workspace.path
local TweenService = game:GetService("TweenService")

for i = 1, #path:GetChildren() do
	local node = path:FindFirstChild('node'..i)
	print(node.Name, i)
	local dist = (root.CFrame.Position - node.CFrame.Position).magnitude
	local speed = 3
	local Time = dist/speed
	
	local info = TweenInfo.new(Time, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
	
	local tween = TweenService:Create(root, info, {
		CFrame = CFrame.new(node.CFrame.Position.X, node.CFrame.Position.Y+2, node.CFrame.Position.Z)  * CFrame.fromEulerAnglesXYZ(root.CFrame:ToEulerAnglesXYZ())
	})
	tween:Play()
	tween.Completed:Wait()

end

this is a very dumb post lol

1 Like

make the zombie spawn like a stud up.
so that it lands on the path,
or maybe put the points a little bit higher to match with the path?

nope, nothing happened.

30 ch_ar

did you try both at the same time

still nothing really changed at all

I’ve tested it out, and for me when I move the points AND the dummy up, the dummy’s new path is more up, not for you?

that also happened to me, that is the problem

ill try it though one more time

if you want the dummy to go slightly up, then can’t you just do that?

to make him be above the path.

i have no idea how, if i know how to do it, i wouldn’t have posted this.

I have a solution, hold on.

The problem is on CFrame = CFrame.new(node.CFrame.Position.X, node.CFrame.Position.Y+2, node.CFrame.Position.Z) * CFrame.fromEulerAnglesXYZ(root.CFrame:ToEulerAnglesXYZ()).

just select the points, and the dummy, then move it up

you just hold control and click the parts to multiselect!

now it’s doing the opposite, now it’s making the dummy go down.

Try this:

local root = script.Parent.HumanoidRootPart

local path = game.Workspace.path
local TweenService = game:GetService("TweenService")

for i = 1, #path:GetChildren() do
	local node = path:FindFirstChild('node'..i)
	print(node.Name, i)
	local dist = (root.CFrame.Position - node.CFrame.Position).magnitude
	local speed = 3
	local Time = dist/speed
	
	local info = TweenInfo.new(Time, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
	
	local tween = TweenService:Create(root, info, {
		CFrame = CFrame.new(node.CFrame.Position.X, root.Position.Y, node.CFrame.Position.Z)  * CFrame.fromEulerAnglesXYZ(root.CFrame:ToEulerAnglesXYZ())
	})
	tween:Play()
	tween.Completed:Wait()

end

I edited this:

CFrame = CFrame.new(node.CFrame.Position.X, node.CFrame.Position.Y+2, node.CFrame.Position.Z)  * CFrame.fromEulerAnglesXYZ(root.CFrame:ToEulerAnglesXYZ())

The solution is:

CFrame = CFrame.new(node.CFrame.Position.X, root.Position.Y, node.CFrame.Position.Z)  * CFrame.fromEulerAnglesXYZ(root.CFrame:ToEulerAnglesXYZ())

Explanation: You need to keep the HumanoidRootPart Position’s Y-value when tweening the HumanoidRootPart.

this code will work for now, thanks

OH, lol.
you need to align the dummy and the points, like what he said, but not coding.

I think?

too late.
welp have a nice day!

If it worked correctly, mark my reply as the solution so others with the same problem can quickly view the answer.