Part placement with difference between two parts

Hello, I am making an ice bird. It goes towards my cursor, but now I have a small problem. I want there to be ice below my bird whenever there’s a part below me, I’ve achieved this with raycasting. But since the part goes to my mouse. It doesnt move in a straight line and at some point it’ll go below the part. Now how would I make it so that the ice will always appear on the part below the bird aslong as the bird is above the part?

Yes sorry I still use the deprecated raycasting.

Here’s my current code:

while true do
					wait()
					local newRay = Ray.new(v.CFrame.p, Vector3.new(0,-3,0).unit * 10)
					local hitPart = game:GetService("Workspace"):FindPartOnRayWithIgnoreList(newRay, ignoreTable2,false,true)



					local function iceslide()
						local slide = game:GetService("ReplicatedStorage"):WaitForChild("Slide"):Clone()
						slide.Parent = workspace.FX
						slide.CFrame = v.CFrame * CFrame.new(0,-3,0)
						game.Debris:AddItem(slide,2)

					end

					if hitPart then
						if hitPart.Material ~= Enum.Material.Air then

							iceslide()
							wait()

						end	
					end

				end

You can use the UpVector/rightVector/lookVector properties of the birds CFrame to get positions relative to it. Or you can simply subtract Vector3(0,dist,0) from its cframe to get a position directly under. Note that subtracting vector3 will not follow orientation.

1 Like