What's Humanoid? Assuming that this is the whole script, you should see a blue underline underneath Humanoid, which means that it's an undefined term. So, what you should do is define it.
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Mouse = Player:GetMouse()
local kicking = Instance.new("Animation", Humanoid)
kicking.AnimationId = "http://www.roblox.com/item.aspx?id=273619670"
local function keyDown(key)
key = key:lower()
if key == 't' then
local animTrack = Humanoid:LoadAnimation(kicking)
animTrack:Play()
end
end
Mouse.KeyDown:connect(keyDown)
That should work.
Although I should note that in here, the KeyDown event is deprecated and should not be used in the future. It's there for compatibility purposes with the older tools.
What you should use for input is UserInputService. This gives you more input mediums such as cell phone devices or Xbox 360 controllers.
Also, I noticed that there's no trace of implementation of a debounce or a wait() function. You should implement them, because they allow a more realistic output for your case. You don't want your character to start to kick if it haven't finished its last kick, do you?
Questions? Comments? Skepticism? Comment down below.
7 comments
Is this the whole script?
Yes
Edited. Try it now.
I did. Still doesn't work. Maybe It's my animation?
Add a print() statement inside the function, see if the function itself works. If it does, then double check on your animation. Make sure that its priority is set to "Action" in your case.
Didn't work.
Your print() function didn't work?