Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to add a punching animation to My character using a hotkey?

Can anyone show me how to add my punching animation to a hotkey, I am a complete begginer at scripting, And i would also appreciate if you showed me how 2 put 3 animations in 1 hot key, For example i press q oce and i punch with my left arm, I press it agai and i punch with my right arm, and press again and i kick. or could u send me to a video that covers this topic, thank you. (I have just finished making the animation i don't know how to put it into my game)

1 answer

Okay, so what you are going to want to do is look into animating.

Helpful links: https://www.youtube.com/watch?v=MUC738JoiFs <-- AlvinBlox https://www.youtube.com/watch?v=ZMAKQXaKsqA <-- PeasFactory

Now once you've come up with your 3 animations, or even you can combine them all into one. Nevertheless, I'll show you both ways you can do it.

LOCALSCRIPT in StarterGui (For one animation):

local plr = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(key, GPE) -- Whenever any key is pressed, this function starts
	if key.KeyCode == enum.KeyCode.E and not GPE then -- If that key was E and they were not chatting then
	
	local anim1 = plr.Character.Humanoid:LoadAnimation(script.Animation1) -- This loads the animation into the player, change the script.Animation1 to whatever animation you are trying to reach

	anim1:Play() -- Plays that animation
	end
end)

Now for 3, basically the same concept:

local plr = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(key, GPE) -- Whenever any key is pressed, this function starts
	if key.KeyCode == enum.KeyCode.E and not GPE then -- If that key was E and they were not chatting then
	
	local anim1 = plr.Character.Humanoid:LoadAnimation(script.Animation1) 
	local anim2 = plr.Character.Humanoid:LoadAnimation(script.Animation2)
	local anim3 = plr.Character.Humanoid:LoadAnimation(script.Animation3)

-- Time to play them,

	anim1:Play() 
	wait(0.5) -- This will need to be adjusted to get perfect timing
	anim1:Stop() -- Stops the first animation, its kind of a safety precaution
	anim2:Play()
	wait(0.5)
	anim2:Stop() -- Stops the second
	anim3:Play()
	wait(0.5)
	anim3:Stop() -- Stops the third
end)

Hopefully this helped or at least pointed you in the right direction :)

This discussion is preserved as it was. New answers, comments, and votes are closed.