Mouse.Hit.P and velocity weird bug

i just idk how to fix it. Any help?

print("spawn knife")
		local knife = game.ReplicatedStorage.Knife:Clone()
		local vel = Instance.new("BodyVelocity",knife.PrimaryPart)
		vel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
		vel.Velocity = (mouse.Hit.Position - knife.PrimaryPart.Position).Unit * 50
		if workspace.TS.Value == true then
			for i,v in pairs(knife:GetChildren()) do
				if v:IsA("BasePart") then
					v.CanCollide = true
					v.Anchored = true
				end
			end
		end
		knife.Parent = workspace
		knife.PrimaryPart.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(0,0,-3)
		knife.PrimaryPart.CFrame = CFrame.new(knife.PrimaryPart.Position, mouse.Hit.Position) * CFrame.Angles(math.rad(-90),0,0)
1 Like

What exactly is the issue? It looks epic from the video.

1 Like

it moves to the wrong direction
not actualy where mouse hits

1 Like

After playing around with your script for a bit I was able to come up with a possible solution. If you move the line

vel.Velocity = (mouse.Hit.Position - knife.PrimaryPart.Position).Unit * 50

to the bottom of the code provided it should work. The problem is that the velocity is referencing the knife’s PrimaryPart position before it is set. Moving that line of code to the bottom should fix the problem because now it will be using the correct Position therefore moving the knife in the right direction.

2 Likes