mario55j
|
  |
| Joined: 13 Aug 2012 |
| Total Posts: 143 |
|
|
| 03 Jan 2016 05:50 AM |
Ok so i have an Animation that I want where when you click x the animation happens
player = game.Players.LocalPlayer
mouse = player:GetMouse()
animation = script:WaitForChild("Animation")
enabled = true
mouse.KeyDown:connect(function(key)
if key == "x" then
if enabled then enabled = false
local animationTrack = player.Character.Humanoid:LoadAnimation(animation) animationTrack:Play()
wait(1.5) enabled = true end end end)
But there is something am confused about how do I make it so the animation keeps happening until you let go of x
thx |
|
|
| Report Abuse |
|
|
mario55j
|
  |
| Joined: 13 Aug 2012 |
| Total Posts: 143 |
|
|
| 03 Jan 2016 06:05 AM |
| anyone? I just want to know what I can do to that script to make it so the animation keeps on going until you let go of x |
|
|
| Report Abuse |
|
|
|
| 03 Jan 2016 06:08 AM |
| local xisdown = game.UserInputService:IsKeyDown(Enum.KeyCode.X) |
|
|
| Report Abuse |
|
|
mario55j
|
  |
| Joined: 13 Aug 2012 |
| Total Posts: 143 |
|
|
| 03 Jan 2016 06:10 AM |
| where do I put that or what do I change to that |
|
|
| Report Abuse |
|
|
mario55j
|
  |
| Joined: 13 Aug 2012 |
| Total Posts: 143 |
|
|
| 03 Jan 2016 06:13 AM |
| and It says UserInputService is not a valid member of DataModel |
|
|
| Report Abuse |
|
|
|
| 03 Jan 2016 06:31 AM |
"game.UserInputService"
game:GetService("UserInputService")
|
|
|
| Report Abuse |
|
|
|
| 03 Jan 2016 06:35 AM |
What you want to do is create a "thread" that repeats until you stop pressing the button and this "thread" breaks.
local looping = false
local loopAnim = function() while(looping)do -- put animation and delay here end end
game:GetService("UserInputService").InputBegan:connect(function(method) if(method.KeyCode == Enum.KeyCode.X)then looping = true loopAnim() end end)
game:GetService("UserInputService").InputEnded:connect(function(method) if(method.KeyCode == Enum.KeyCode.X)then looping = false end end) |
|
|
| Report Abuse |
|
|
mario55j
|
  |
| Joined: 13 Aug 2012 |
| Total Posts: 143 |
|
|
| 03 Jan 2016 06:38 AM |
so like this? player = game.Players.LocalPlayer
local looping = false
local loopAnim = function() while(looping)do http://www.roblox.com/asset?id=339025390 (1.5) end end
game:GetService("UserInputService").InputBegan:connect(function(method) if(method.KeyCode == Enum.KeyCode.X)then looping = true loopAnim() end end)
game:GetService("UserInputService").InputEnded:connect(function(method) if(method.KeyCode == Enum.KeyCode.X)then looping = false end end) |
|
|
| Report Abuse |
|
|
mario55j
|
  |
| Joined: 13 Aug 2012 |
| Total Posts: 143 |
|
|
| 03 Jan 2016 06:47 AM |
or do you mean like this
local looping = false
animation = script:WaitForChild("Animation") player = game.Players.LocalPlayer
local loopAnim = function() while(looping)do local animationTrack = player.Character.Humanoid:LoadAnimation(animation) animationTrack:Play()end end
game:GetService("UserInputService").InputBegan:connect(function(method) if(method.KeyCode == Enum.KeyCode.X)then looping = true loopAnim() end end)
game:GetService("UserInputService").InputEnded:connect(function(method) if(method.KeyCode == Enum.KeyCode.X)then looping = false end end) |
|
|
| Report Abuse |
|
|
| |
|
mario55j
|
  |
| Joined: 13 Aug 2012 |
| Total Posts: 143 |
|
|
| 03 Jan 2016 06:52 AM |
Cody the second one just makes you get shut downed
sorry if I don't get it fast am new |
|
|
| Report Abuse |
|
|
mario55j
|
  |
| Joined: 13 Aug 2012 |
| Total Posts: 143 |
|
|
| 03 Jan 2016 06:53 AM |
| And the first one does not work |
|
|
| Report Abuse |
|
|