Need help making knife throw ability

What I want the results to be.
I want my knife throws to be more accurate. The problem is detecting when the knife is touched and how the knife throw can go perfectly straight. It works great with damaging NPC and players, but what I’m concerned with is when the knife touches a wall or object and the direction of the knife.

What happens.
I used the touched event in the same way as the damaging function, yet yielded terrible results. I threw the knife at a wall, and the knife doesn’t even touch the wall by the time it is anchored. The knife went through the wall because cancollide was off, but then anchored and kept floating in the air. When I threw the knife, the direction of the knife was terrible too, it kept facing sideways and not forward to the target.

What I tried to fix it.
I went searching on the dev forum and saw Region3 and GetTouchingParts(), but didn’t even know how to use them. I tried doing the touching parts thing, but it doesn’t work on cancollide objects. I tried looking at region3 and was immediately confused, but then saw on a dev forum about the region3 saying that touched was better than region3 in my situation. Then I went searching on the dev forum even more and found out that touched is terrible when it comes to high-speed moving objects.

Here’s the knife throw script.

Note: The require at the first line of the code is really useful, it’s basically merging a local script and a script, allowing you to do game.Players.LocalPlayer on a script.

Script < this is inside a player’s character

require(3747589551)()
-- put scripts under here! --
repeat wait() until script.Parent:IsA("Model")
local p = game.Players.LocalPlayer
local char = p.Character
local hed = char.Head

local LeftArm2 = char["Left Arm"]
local RightArm2 = char["Right Arm"]
local LeftLeg2 = char["Left Leg"]
local RightLeg2 = char["Right Leg"]
local Torso2 = char.Torso

local shirt = char:WaitForChild("Shirt")
local pants = char:WaitForChild("Pants")

wait()
shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=536831523"
pants.PantsTemplate = "http://www.roblox.com/asset/?id=547264976"

oldknife = script.Knife
oldknife.Parent = game.ServerStorage

char.Humanoid.MaxHealth = math.huge
char.Humanoid.Health = math.huge

char.Humanoid:RemoveAccessories()

local Hair = Instance.new("Part")
Hair.Parent = char
Hair.Name = "Hair"
Hair.Size = Vector3.new(1, 1, 1)
Hair.CFrame = char.Head.CFrame
Hair:BreakJoints()
Hair.CanCollide = false
Hair.TopSurface = "Smooth"
Hair.BottomSurface = "Smooth"
Hair.BrickColor = BrickColor.new("Gold")
Weld = Instance.new("Weld") 
Weld.Name = "Weld"
Weld.Part0 = char.Head 
Weld.Part1 = Hair
Weld.Parent = char.Head 
Weld.C0 = CFrame.new(0.1,0,0.2)*CFrame.fromEulerAnglesXYZ(0,0,0) 
Mesh = Instance.new("SpecialMesh")
Mesh.Parent = Hair
Mesh.MeshId = "rbxassetid://886288384"
Mesh.TextureId = "rbxassetid://886289004"
Mesh.Scale = Vector3.new(0.11,0.1,0.08)

cut = Instance.new("Sound", char)
cut.SoundId = "https://www.roblox.com/asset/?id=97095069"
cut.Volume = 1.5
thri = Instance.new("Sound", char)
thri.SoundId = "https://www.roblox.com/asset/?id=186311262"
thri.Volume = 2.5
WRY = Instance.new("Sound", char)
WRY.SoundId = "https://www.roblox.com/asset/?id=910713928"
WRY.Volume = 5

ff = Instance.new("ForceField", char)
ff.Visible = false

local Mouse = p:GetMouse()
local RenderStepped = game:service'RunService'.RenderStepped

local MeshId = 'http://www.roblox.com/asset?id=202083123'
local TextureId = 'http://www.roblox.com/asset/?id=189436355'

local KnifeSpeed = 120

local uis = game:GetService("UserInputService")

uis.InputBegan:Connect(function(input, gameProcessed)
	if gameProcessed then
		return
	end

	if input.KeyCode == Enum.KeyCode.E then
		cut:Play()
		if Mouse.hit.p then
			local Knife = oldknife:Clone()
			local mousePos = Mouse.hit.p
			
			Knife.CFrame = Torso2.CFrame
			
			local knifeBV = Instance.new("BodyVelocity",Knife)
			knifeBV.MaxForce = Vector3.new(1e6,1e6,1e6)
			knifeBV.Velocity = CFrame.new(Knife.Position, mousePos).LookVector * KnifeSpeed
			
			Knife.Parent = char
			
			coroutine.wrap(function()
				RenderStepped:connect(function()
					if workspace:FindFirstChild'TimeIsStopped' and Knife.Name == 'Knife' then
						Knife.Anchored = true
					else
						Knife.Anchored = false
					end
					
					if Knife.Name == 'WallKnife' then
						Knife.Anchored = true
					end
				end)
			end)()
			Knife.Touched:connect(function(p)
				if p.Parent ~= char and p.Parent:FindFirstChild'Humanoid' then
					p.Parent:BreakJoints()
					Knife:Destroy()
					thri:Play()
					print('Humanoid')
				end
				if not p.Parent:IsDescendantOf(char) and not p.Parent:FindFirstChild'Humanoid' then
					if Knife.Name == 'WallKnife' then return end
					Knife.Anchored = true
					Knife.CanCollide = false
					Knife.Name = 'WallKnife'
					knifeBV:Destroy()
					thri:Play()
					print('Wall')
				end
			end)
		end
	end
end)

clear = function()
	for i,v in pairs(char:GetChildren()) do
		if v.Name == 'Knife' or v.Name == 'WallKnife' then
			v:Destroy()
		end
	end
end

uis.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.R then
		clear()
	end
end)

Just let me know my mistake, how I can fix it, and if you want to, send me some compatible code (non-mandatory). For those asking, yes this is a Jojo script.

i think it detects the model as a whole, could you try just making a part as a wall and tell me what happens?

Alright, I’m gonna go test what happens

also pardon me if I am wrong, but isn’t there supposed to be “()” in there?

Actually there doesn’t need to be “()”, also right now im trying to fix body colors so ill reply to the test if it detects the model as a whole post when i can

image

Alright, I have to go offline now. I’ll check back here tomorrow.