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

Multiple animations played with one script?

Right so here is what I have so far:



Tool = script.Parent
local player = game.Players.LocalPlayer
repeat wait() until player.Character ~= nil
local hum = player.Character:WaitForChild("Humanoid")



Tool.Activated:connect(function(mouse) 
	local animation = Tool.Taunt
local AnimTrack = hum:LoadAnimation(animation) 
        AnimTrack:Play()

Tool.Unequipped:connect(function()
    AnimTrack:Stop()
end)
    end)
	

And I want to make it so lets say I press L and it does another animation. I have no idea how to make this work. Also if I'm going to use keyboard inputs I'm guessing a local script correct?

1 answer

✓ Accepted answer

I am guessing that you know how to play animations by your main post.

I like to use UserInputService, so for the letter L:

function onKeyPress(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.L then
		--Animation code here!
	end
end
 
game:GetService("UserInputService").InputBegan:connect(onKeyPress) --When a key is pushed down(Not when released)

The link below should be easy for you to use keyboard inputs. http://bfy.tw/7dpT

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