How to make a Murder Mystery knife [Part One o.o]

Welcome everyone to this Tutorial!

What are we gonna do today? Let me tell you.
So you know the game Murder Mystery 2 right? There are tons of copies of it, but that one is the original. Today, I’m going to show you how to make a simple knife that can kill and it comes with a super fancy animation too! Ready? Let’s get started!

This tutorial will cover the:

  • Animations
  • And the actual script.

Oh also:

0. The knife itself

Almost forgot about this lol.

But this is super easy to do. Just open the toolbox and throw in a knife mesh (You should look at the meshes category). Obviously check if it has any scripts with bad intentions, and if you find any, Delete them. Then insert a tool object and put the knife handle in it.

Also add a hitbox to your knife. This is the zone where the knife will actually kill people.

All you gotta do, is just insert a part, resize it to the size of the knife (Or you could make it bigger :skull:), and weld it to the knife itself. You just have to insert a WeldConstraint to the hitbox, set the part0 to the hitbox part, and the part1 will be the knife.

You can test this out by putting the tool in starterpack and playing the game. If your character suddently teleports somewhere, then you might have forgotten to unanchor the hitbox.

1. Animation

So much typing

Anyway, now it’s time for the animation! For this, I’m going to use the basic Roblox Animation
Editor Plugin, since everyone has it.

So, insert a dummy (Block or mesh rig is the best), turn on the plugin, then select a dummy.
Now, you’ll be prompted with a window asking you to name your animation something.
I don’t care what you name it to be honest.
And now, the animation. It shouldn’t be a really complicated animation, Just move the hand like it’s stabbing. It should be around 1 - 1,5 seconds long.

When you’re done, click on the 3 dots on the top of the plugin window, and it should show a list. at the top, you see a save button. Click it. Then you can publ-

WAIT

This is a really important thing when you make this animation, the Priority

At the bottom of the list, there’s the Animation Priority setting. Set it to Action.

If you don’t do this, the whole thing won’t work. The point is, don’t leave it on Core.

If you want to know why, check the comments.

Now, you can publish the animation to Roblox. If you want to make changes, just publish the animation, but before you click that bright blue button, there’s an option at the down left corner to update an already existing asset. Then select your animation. Boom.

2. Scripting

Here we go, the technical part.

Insert a Localscript into the handle, and delete the print line.

first, define the variables:

local Handle = script.Parent
local Tool = Handle.Parent

Next, the actual code. This is easier than you might think. All you gotta do, is just have a
local boolean set in the script, and when the tool is activated (Basically when the player clicks when the tool is equipped) then just set that boolean to true, and a few seconds later, just set it back to false.

local canKill = false

Tool.Activated:Connect(function()
	if not canKill then
		canKill = true
		wait(1)
		canKill = false
	end
end)

Now, make a touched Event, so if the tool is touched, then just kill/damage the player.

Handle.Touched:Connect(function(hit)
	if canKill then
		if hit.Parent:FindFirstChild("Humanoid") then
			hit.Parent.Humanoid.Health -= 110
		end
	end
end)

Now if you try it, then… well… nothing happens?

How about you spam click and move continuously?

Ah yes, the dummy is now killed. But why didn’t it work first time?

Thats because the touchedEvent fires everytime the target part collides with anything else. Basically the TouchedEvent might not have the canKill set to true. You can check it by setting the waittime into a bigger number in the activated function. Works now? Good.

This is how we solve the Touched Problem:

Remember the animation you’ve made?
Create an animation object, and paste the animation’s ID inside the animationID, then Put it into the handle. We will do a LoadAnimation() function to make the character play the animation.

However, how do we know who’s the tool’s parent?

Just add an equipped function and some other variables:

local Animation = Handle["Slash1"] -- obviously change this to your Animation name.

local plr = nil

Tool.Equipped:Connect(function()
	plr = Tool.Parent
end)

And finally, before the wait() in the Activated function, add this line:

local anim = plr.Humanoid.Animator:LoadAnimation(Animation)
anim:Play()

Test time!

The animation should play. If not, check the Output for any info. If there’s a big red text, then you’ve just got slapped with an error. Maybe you’ve made a spelling mistake, if so, correct it.

But after a while, it should look like this:

I really hope the video loaded

Anyway, the knife will play the slash animation, and it will actually damage people!

I really hope this tutorial was helpful, because OH MY GOD SO MUCH TYPING AHHHHHH

Bye.

15 Likes

For the people that were Actually curious, the reason to not leave it on core, is because I had the exact problem when I was making the knife for a game. Basically, the animation wouldn’t load. Here’s a hyperlink to the thread:

Click me please!

2 Likes

Hello, The tutorial is great! You explained it pretty well, and simpified the code so it’s readable for newer programmers.

For the animation part, it would be extremely helpful if you put images so we can go along with the tutorial.

Animating is my weakness.

It would be very nice to credit him, but I don’t think that you might get a warning for it.

This tutorial isn’t a direct copy, since the animation in this tutorial is far from being the same and the script definitely isn’t the same.

1 Like

Why not use instead Humanoid.Health = 0?

If someone was following along with the tutorial but wanted multiple slashes to kill someone then they could easily adapt it to that. With your way they have to rewrite that whole line. I believe this is the main reason he did -= instead of just = 0.

1 Like

That’s not how this kind of stuff works buddy.

2 Likes

Great little tutorial you’ve got here. I recommend maybe adding some more photos for people that are more visual leaners, but otherwise this is great!

You don’t need to credit people for things you recreate. You would never get warned for something like that unless you straight-up stole assets from the game.

Hello!

The reason I did this instead of just setting it to 0 is because I heard that setting it to 0 doesn’t always work, and there’s a chance that the victim will survive. When I made killParts and such, I always used the BreakJoints() function upon touching the part. Yea. This is it. Just making sure, and the victim will die anyway, right?