Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is my Raycasting NPC roaming around randomly?

BY THE WAY I DO KNOW THAT THE BACK-RAY IS NOT BEING TESTED FOR! Running in a server script, inside of an AI's torso. The problem is when I try to get him to follow me with the first ray, I get this: Youtube Video

wait(1)
while wait() do
	local frontRay =Ray.new(script.Parent.CFrame.p,script.Parent.CFrame.lookVector*300)
	local backRay= Ray.new(script.Parent.CFrame.p,script.Parent.CFrame.lookVector*-300)
	local part,pos=game.Workspace:FindPartOnRayWithIgnoreList(frontRay,script.Parent.Parent:GetChildren())
	if part ~= nil then
	print(part.Name)
	print(part.Parent.Name)
		if part.Parent:FindFirstChild("Humanoid") then
		script.Parent.Parent.Humanoid:Move(part.Parent.Torso.Position)
		print("moving")
end
end
end

2 comments

0

the second paramater for FindPartOnRayWithIgnoreList should be a table. ?

0

It is. its "script.Parent.Part:GetChildren()" or something

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.