Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to add an OnTouched Hotkey Punching animation?

Asked by 8 years ago
Edited 8 years ago

Sorry once again, I sound like a beggar but, Could you teach me how I would do this. Also, that when you touch the humanoid it does like -5 damage. I would also like to know that each time when that person presses the certain key it changes the animation every time.

Much Thanks.

0
I suggest you to check my answer :) superalp1111 662 — 8y
0
I know you don't want to sound like a begger, but most of these answers are on the wiki.... like random numners etc. Please read the wiki if you can. H4X0MSYT 536 — 8y

3 answers

Log in to vote
0
Answered by
Etheroit 178
8 years ago

Put this in the localscript parented to the part in the weapon (hitbox)

1local part = script.Parent -- here insert location of the part which will damage someone after hitting him
2part.Touched:connect(function(hit)
3if hit.Parent:FindFirstChild("Humanoid") then
4local plr = game.Players:GetPlayerFronCharacter(hit.Parent)
5if plr ~= nil then
6hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 5 -- change damage here
7end
8end
9end)
0
I meant when you press the key you do a punch Daiko_King 1 — 8y
0
ouch You need animatoons then. I cant do this because Im on phone. Etheroit 178 — 8y
0
I have animations but I do not know how to put it in the script :P Daiko_King 1 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

First of all, create animations.

Second, use this LINK to understand mechanics of animations.

And lastly, check Health property to see how you can damage the player.

Basically, there are a few examplesin these links that is very simple. For that, you need to insert "Animation" object into somewhere into the game, then you need to change their IDs to your animations' IDs. You said there are more than one animations so I will show you how to play animations randomly in each click. After you get your animations into a safe place(ServerStorage is pretty good for these stuff) you need to insert a LocalScript into StarterPack or StarterGui and, you can basically copy and paste this or read descriptions to fully understand and remake it. I am making it for three animations, you can change it later.

01--Firstly, we create an array that will hold our animations. Let's say our animations in a folder named "Animations" and it's in ServerStorage. And let's say our animations' names are Anim1, Anim2 and Anim3
02Anims = {
03game.ServerStorage.Animations.Anim1, --See how we do this? Variant, Variant, Variant
04game.ServerStorage.Animations.Anim2, --Never forget Commas unless you type last Variant
05game.ServerStorage.Animations.Anim3  --We do not put Comma at the end of last Variant.
06}--Didn't understand how arrays work? Check this [LINK](http://wiki.roblox.com/index.php?title=Table&redirect=no#Arrays).
07--Also we will need a bool for stop punching without waiting.
08Busy = false
09Damage = 5--The damage punching will cause.
10 
11--Now we need to create our function, for keypress event(Keyboard Input). Check this [LINK](http://wiki.roblox.com/index.php?title=Keyboard_input) for more info about keyboard inputs.
12 
13--I will use UserInputService for my example
14function onKeyPress(inputObject, gameProcessedEvent)
15    if inputObject.KeyCode == Enum.KeyCode.F then
View all 49 lines...

I hope this helped you! Took my 20 minutes to type descriptions, study this hard :)

0
This looks pretty good! I'll try this too! marioblast1244 113 — 8y
Log in to vote
-1
Answered by 8 years ago

i think i know how LEARN!

0
I think I know how to not lose reputation. Type COMMENT if you are not DESCRIBING! superalp1111 662 — 8y

Answer this question