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

Key Press Animation Won't Play?

When you touch this brick, it will clone this local script into the players Gui. However, it doesn't work whenever I press h...


local Mouse = game.Players.LocalPlayer:GetMouse()
local chr = game.Players.LocalPlayer.Character

function onKeyDown(key)
	key = key:lower()
	if key == "h" then
		local animation = Instance.new("Animation")
		animation.AnimationId = "http://www.roblox.com/Asset?ID=1567452314"
		wait()
		local trackanimation = chr.Humanoid:LoadAnimation(animation)
		trackanimation:Play()
	end
end

Mouse.KeyDown:connect(onKeyDown)

1 answer

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Human = Character:WaitForChild("Humanoid")
local Mouse = Player:GetMouse()
local anim = Instance.new("Animation", Human)
anim.AnimationId = "http://www.roblox.com/asset/?id=01468567293" --Type your animation id here

mouse.KeyDown:connect(function(key)
	    key = key:lower()
	if key == 'h' then
			local animTrack = Human:LoadAnimation(anim)
			animTrack:Play()
	end
end)

This script should work.

And don't make it in local script, use normal script.

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