Nicoehh
|
  |
| Joined: 18 Nov 2014 |
| Total Posts: 119 |
|
|
| 05 Dec 2016 10:01 AM |
| Ok so I need help how do I play an animation when you have some tool equipped and press some key like "Q" ? |
|
|
| Report Abuse |
|
|
|
| 05 Dec 2016 10:05 AM |
--In the tool, as a Script
function UseKey(key) if key == "q" then local anim = script.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Animation) --Put the animation in the tool anim:Play() end end
script.Parent.Equipped:connect(function(mouse) mouse.KeyDown:connect(UseKey) end) |
|
|
| Report Abuse |
|
|
VioXz
|
  |
| Joined: 12 May 2014 |
| Total Posts: 12 |
|
|
| 05 Dec 2016 10:06 AM |
^ no use UserInputService
- OnlySinister |
|
|
| Report Abuse |
|
|
| |
|
Nicoehh
|
  |
| Joined: 18 Nov 2014 |
| Total Posts: 119 |
|
|
| 05 Dec 2016 10:12 AM |
| It didn't work for me, but thanks for reply. |
|
|
| Report Abuse |
|
|
|
| 05 Dec 2016 10:15 AM |
| did you put it into a tool? with an animation? Post the Error from the Output. |
|
|
| Report Abuse |
|
|
Nicoehh
|
  |
| Joined: 18 Nov 2014 |
| Total Posts: 119 |
|
|
| 05 Dec 2016 10:29 AM |
| There is no error in output and yes I had the animation in tool! |
|
|
| Report Abuse |
|
|
xXLuka_XD
|
  |
| Joined: 27 Mar 2016 |
| Total Posts: 296 |
|
|
| 05 Dec 2016 11:03 AM |
| Key Down doesn't work perfect for everyone. Suggest using UserInputService |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 05 Dec 2016 12:26 PM |
"It doesn't matter."
You're a moron if you have that kind of attitude.
|
|
|
| Report Abuse |
|
|
Nicoehh
|
  |
| Joined: 18 Nov 2014 |
| Total Posts: 119 |
|
| |
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 05 Dec 2016 12:27 PM |
--local script
local uis = game:GetService('UserInputService')
uis.InputBegan:connect(function(input,event) if input.KeyCode == Enum.KeyCode.Q then --load animation end end)
|
|
|
| Report Abuse |
|
|
spinywind
|
  |
| Joined: 26 Jan 2012 |
| Total Posts: 3580 |
|
|
| 05 Dec 2016 01:59 PM |
^ Do what time ticks did, dont listen to dark. UserInputService is a lot better.=, keydown/up is deprecated.
#Code print(print(print(print(print(print(print()))))))) |
|
|
| Report Abuse |
|
|
Nicoehh
|
  |
| Joined: 18 Nov 2014 |
| Total Posts: 119 |
|
|
| 05 Dec 2016 06:11 PM |
| It still doesn't play the anim. By the way this is for a tool so :P |
|
|
| Report Abuse |
|
|
|
| 05 Dec 2016 06:17 PM |
did you load the animation
|
|
|
| Report Abuse |
|
|
Roblok1
|
  |
| Joined: 27 Jul 2011 |
| Total Posts: 2019 |
|
|
| 05 Dec 2016 06:34 PM |
anim = humanoid:LoadAnimation (tool.animation) anim:Play () |
|
|
| Report Abuse |
|
|
|
| 07 Dec 2016 08:53 AM |
| Well Non-Existant Christ, ya don't gotta be that rude to me, I'm so sorry for being an Old Timer. |
|
|
| Report Abuse |
|
|
jmbooth
|
  |
| Joined: 10 Oct 2012 |
| Total Posts: 13 |
|
|
| 07 Dec 2016 09:03 AM |
Tool = script.Parent equipped = false local UIP = game:GetService('UserInputService')
Tool.Equipped:connect(function() equipped = true end)
Tool.unequipped:connect(function() equipped = false end)
UIP.InputBegan:connect(function(input) if UIP:GetFocusedTextBox() == nil then if input.KeyCode == Enum.KeyCode.Q and equipped then --animationscript here end end end)
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 07 Dec 2016 09:05 AM |
@jm
if not event then return end
why would anyone do getfocusedtextbox. gross
|
|
|
| Report Abuse |
|
|
jmbooth
|
  |
| Joined: 10 Oct 2012 |
| Total Posts: 13 |
|
|
| 07 Dec 2016 09:07 AM |
So it doesn't work when chatting
|
|
|
| Report Abuse |
|
|
jmbooth
|
  |
| Joined: 10 Oct 2012 |
| Total Posts: 13 |
|
|
| 07 Dec 2016 09:10 AM |
UIP.InputBegan:connect(function(input) if input.KeyCode ~= Enum.KeyCode.Q and not equipped then elseif onput.KeyCode == Enum.KeyCode.Q and equipped then --animation script here end end)
|
|
|
| Report Abuse |
|
|
jmbooth
|
  |
| Joined: 10 Oct 2012 |
| Total Posts: 13 |
|
| |
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 07 Dec 2016 09:14 AM |
yes like i said
uis.InputBegan:connect(function(input,event) if event then return end --if player is chatting
|
|
|
| Report Abuse |
|
|
HlCOM
|
  |
| Joined: 29 Mar 2009 |
| Total Posts: 3332 |
|
|
| 07 Dec 2016 09:15 AM |
| if you're gonna tell someone to use something that's deprecated then you shouldn't be posting advice. |
|
|
| Report Abuse |
|
|
|
| 07 Dec 2016 09:23 AM |
| UserInputService isn't deprecated. |
|
|
| Report Abuse |
|
|
Lykaon
|
  |
| Joined: 27 Oct 2014 |
| Total Posts: 784 |
|
|
| 07 Dec 2016 09:24 AM |
| Remove is deprecated, use script.Parent = nil instead. |
|
|
| Report Abuse |
|
|