so my idea was when you press z it plays an animation of you sitting down and then 1.6 seconds later it plays the looping seated animation .
what happens is if you press z nothing happens and if you press it again you are seated.
its skipping the sitting down animation
any help i can get is appreciated
01 | local player = game.Players.LocalPlayer |
02 | repeat wait() until player.Character.Humanoid |
03 | local humanoid = player.Character.Humanoid |
04 | local mouse = player:GetMouse() |
05 |
06 | local SD = game.Workspace.SittingDown |
07 | SD.AnimationId = "http://www.roblox.com/asset/?id=933356177" |
08 |
09 | local S = game.Workspace.Seated |
10 | SD.AnimationId = "http://www.roblox.com/asset/?id=933369397" |
11 |
12 | mouse.KeyDown:connect( function (key) |
13 | if key = = "z" then |
14 | local playAnim = humanoid:LoadAnimation(SD) |
15 | playAnim:Play() |
If you want to make a key input use UserInputService
there is 2 ways, the first way is the more right way, but the other way if you want a "looped" check
01 | --This needs to be inside a localscript, otherwise will not work |
02 | local service = game:GetService( "UserInputService" ) |
03 |
04 | service.InputBegan:connect( function (obj) |
05 | if obj.KeyCode = = Enum.KeyCode.Z then |
06 | local playAnim = humanoid:LoadAnimation(SD) |
07 | playAnim:Play() |
08 | wait( 1.6 ) |
09 | local playAnim = humanoid:loadAnimation(S) |
10 | playAnim:Play() |
11 | end |
12 | end |
13 |
14 | --this is the function to make you press a button that does something, example, pressing Shift ------does make you run |