How can i make a knife similar to The Mad Murderer or MM2?

I would like to know what concepts i need to know or a guideance of how to make a knife similar to The mad murderer or MM2 ik it has smth to do with angular velocity and body force but i dont know how could i make it

I was able to code a quick prototype of what you want:

The prototype is basically making use of AngularVelocity and LinearVelocity. Here’s the messy code that I wrote in a few minutes:

local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local Tool = script.Parent

local Throwable = game:GetService("ReplicatedStorage"):WaitForChild("Throwable")

Tool.Activated:Connect(function()
	-- get camera
	local camera = workspace.CurrentCamera
	if not camera then warn("No camera found") return end
	
	-- get lookat
	local lookVector = camera.CFrame.LookVector
	
	-- create projectile at camera position (assuming the game is in first person, otherwise you'd have to do more vector3/cframe math)
	local projectile = Throwable:Clone()
	projectile.CFrame = camera.CFrame
	projectile.Parent = workspace
	
	projectile:WaitForChild("LinearVelocity").VectorVelocity = lookVector * 32
	
	local connection
	connection = projectile:WaitForChild("Collider").Touched:Connect(function(otherPart: BasePart)
		if otherPart:IsDescendantOf(Player.Character) then return end
		projectile.Anchored = true
		connection:Disconnect()
	end)
end)

Please not that this code is not well made and has no server-client functionality, it’s solely client-sided and was made for the prototype only.

I hope this helps you in some way.

Thank you so much! i will check the code and modify it as my likings but this helps a lot

1 Like

Soi integrated some of your code but its not working as intended

here a video of whats happening

this is my code

function module:Throw()
	
	
	local lookVector = self.Player:GetMouse().Hit.Position
	
	local Projectile = self.Tool.Handle:Clone()
	Projectile.CFrame = self.Tool.Handle.CFrame
	Projectile.WeldConstraint:Destroy()
	Projectile.Name = "Projectile"
	Projectile.Parent = workspace
	
	
	local Velocity = Instance.new("LinearVelocity")
	Velocity.Parent = Projectile
	
	Velocity.VectorVelocity = lookVector * 35
	Velocity.Attachment0 = Projectile.VelocityAtt
	

	print(Velocity.VectorVelocity)
	
	local Connection
	Connection = Projectile.Touched:Connect(function(part:BasePart)
		if part:IsDescendantOf(self.Player.Character) then return end
		Projectile.Anchored = true
		Connection:Disconnect()
	end)
	
end

In my code, we we’re able to get the LookVector directly from the Camera, but of course that wouldn’t work if you were in third person.

Now, the new version of the code has the following variables:
origin: The Vector3 from where you want the knife to be thrown.
target: The Vector3 that will be used to determine the direction of the lookVector variable.

I’ve modified your code so it works properly:

function module:Throw()

	local origin = self.Player.Character.PrimaryPart.Position
	local target =  self.Player:GetMouse().Hit.Position

	local lookVector = (target - origin).Unit

	local Projectile = self.Tool.Handle:Clone()
	Projectile.CFrame = self.Tool.Handle.CFrame
	Projectile.WeldConstraint:Destroy()
	Projectile.Name = "Projectile"
	Projectile.Parent = workspace


	local Velocity = Instance.new("LinearVelocity")
	Velocity.Parent = Projectile

	Velocity.VectorVelocity = lookVector * 35
	Velocity.Attachment0 = Projectile.VelocityAtt


	print(Velocity.VectorVelocity)

	local Connection
	Connection = Projectile.Touched:Connect(function(part:BasePart)
		if part:IsDescendantOf(self.Player.Character) then return end
		Projectile.Anchored = true
		Connection:Disconnect()
	end)

end

For some reason this still dopesnt work at all i think it has to do with the force being applied not being applied at all not sure though also the collision is not working at all too

External Media

I’m using the same code you provided and it seems to be working normal for me. Are you able to share the .rbxl file?

Sure! here is the rbxl file (dont mind the free model knife it was to check the code lol)
knife thingy.rbxl (82.0 KB)

Alright, so the issue was that the ForceLimitsEnabled boolean value of the LinearVelocity was set to true, once you set it to false it should work.

I see tysm! this helps a lot for sure appreciate it (though it still doesnt anchors)

You need to set CanTouch to true for the Handle.

Also, this calculation is more accurate:

	local origin = self.Tool.Handle.Position
	local target =  self.Player:GetMouse().Hit.Position

	local lookVector = (target - origin).Unit

We’re using the handle position instead.

And for thr angular velocity do i have to use another attachment or how bc its not working and sorry for much asking ive been hours researching

No you can use the same attachment. You just set the AngularVelocity relative to Attachment0 and modify the MaxTorque and AngularVelocity value to your liking.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.