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

how to u make a keypress event play a animation?

i made an animation wheere a player does something how do i make it if key 'r' is presset then the character does that animation

1 comment

0

local player = game.Players.LocalPlayer local Mouse = player:GetMouse() Mouse.KeyDown:connect(function(key) if key == "r" then s = player.Character.Humanoid:LoadAnimation(LOCATION OF ANIMATION HERE) s:Play() end) --Helped by xXSolarSolisticXx

1 answer

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

m.KeyDown:Connect(function(key)
if key == "q" then --Edit this
local anim=Instance.new("Animation",workspace)
anim.AnimationId = "http://www.roblox.com/Asset?ID=0000" -- Put id here
local animTrack = player.Character.Humanoid:LoadAnimation(anim)
animTrack:Play()
end
end)

2 comments

1

keydown is deprecated. UIS is better

0

Yeah, it sends wrong messages.

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