Advertisement
D_rawest16

Untitled

Feb 17th, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 KB | None | 0 0
  1. player = game.Players.LocalPlayer
  2. TweenS = game:GetService("TweenService")
  3. uis = game:GetService("UserInputService")
  4. Char = player.Character or player.CharacterAdded:Wait()
  5. CharHum = Char:WaitForChild("Humanoid")
  6. camera = game.Workspace.CurrentCamera
  7. run = game:GetService("RunService")
  8. re = game.ReplicatedStorage.Event.PassEvent
  9. speed = CharHum.WalkSpeed
  10. Sp_Db = false
  11. db = false
  12. Toggle_Db = true
  13.  
  14.  
  15.  
  16. if speed == 0 then speed = 30 end
  17. if not CharHum then return end
  18.  
  19. W = script:WaitForChild("W")
  20. S = script:WaitForChild("S")
  21. A = script:WaitForChild("A")
  22. D = script:WaitForChild("D")
  23. FA = script:WaitForChild("FullA")
  24. FD = script:WaitForChild("FullD")
  25. Idle = script:WaitForChild("Idle")
  26.  
  27. MasterControl = require(game.Players.LocalPlayer:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"):WaitForChild("ControlModule"))
  28. Directions = {
  29. Idle = {Vector3.new(0, 0, 0), "Idle"};
  30. Go = {Vector3.new(0, 0, -1), "Go"};
  31. Back = {Vector3.new(0, 0, 1), "Back"};
  32. Right = {Vector3.new(1, 0, 0), "Right"};
  33. Left = {Vector3.new(-1, 0, 0), "Left"};
  34. AD_Right = {Vector3.new(1, 0, -1), "AD_Right"};
  35. AD_Left = {Vector3.new(-1, 0, -1), "AD_Left"};
  36. AA_Right = {Vector3.new(1, 0, 1), "AA_Right"};
  37. AA_Left = {Vector3.new(-1, 0, 1), "AA_Left"}
  38. }
  39. anim_Table = {
  40. W = CharHum:LoadAnimation(W);
  41. S = CharHum:LoadAnimation(S);
  42. A = CharHum:LoadAnimation(A);
  43. D = CharHum:LoadAnimation(D);
  44. FA = CharHum:LoadAnimation(FA);
  45. FD = CharHum:LoadAnimation(FD);
  46. Idle = CharHum:LoadAnimation(Idle);
  47. }
  48. info = TweenInfo.new(3.5,Enum.EasingStyle.Quint,Enum.EasingDirection.Out,0,false,0)
  49. Create_Tween = TweenS:Create(CharHum,info,{WalkSpeed = game.StarterPlayer.CharacterWalkSpeed})
  50.  
  51. function stop(name)
  52. for i,v in pairs(anim_Table) do
  53. v:Stop()
  54. end
  55. Create_Tween:Play()
  56. end
  57.  
  58. anim_Table.Idle:Play()
  59.  
  60. if uis.MouseBehavior == Enum.MouseBehavior.LockCenter then
  61. db = false
  62. else
  63. db = true
  64. if (CharHum.MoveDirection).Magnitude > 0 then
  65. stop()
  66. anim_Table.W:Play()
  67. end
  68. end
  69.  
  70. function Movement()
  71. if not db and not Sp_Db then
  72. local move = MasterControl:GetMoveVector()
  73. if move == Directions.Go[1] then
  74. stop()
  75. anim_Table.W:Play()
  76. elseif move == Directions.Back[1] then
  77. stop()
  78. anim_Table.S:Play()
  79. elseif move == Directions.Right[1] then
  80. stop()
  81. anim_Table.FD:Play()
  82. elseif move == Directions.Left[1] then
  83. stop()
  84. anim_Table.FA:Play()
  85. elseif move == Directions.Idle[1] then
  86. stop()
  87. Create_Tween:Cancel()
  88. CharHum.WalkSpeed = 0
  89. anim_Table.Idle:Play()
  90. elseif move == Directions.AA_Left[1] then
  91. stop()
  92. anim_Table.A:Play()
  93. elseif move == Directions.AA_Right[1] then
  94. stop()
  95. anim_Table.D:Play()
  96. elseif move == Directions.AD_Left[1] then
  97. stop()
  98. anim_Table.A:Play()
  99. elseif move == Directions.AD_Right[1] then
  100. stop()
  101. anim_Table.D:Play()
  102. end
  103. elseif db then
  104. if (CharHum.MoveDirection).Magnitude == 0 and not Toggle_Db and not Sp_Db then
  105. stop()
  106. Toggle_Db = true
  107. Create_Tween:Cancel()
  108. CharHum.WalkSpeed = 0
  109. anim_Table.Idle:Play()
  110. end
  111. end
  112. end
  113.  
  114. function BeganKeys(key,chat)
  115. if not chat then
  116. if uis.MouseBehavior ~= Enum.MouseBehavior.LockCenter and db then
  117. if script:FindFirstChild(key.KeyCode) and Toggle_Db and not Sp_Db then
  118. stop()
  119. Toggle_Db = false
  120. anim_Table.W:Play()
  121. end
  122. else
  123. db = false
  124. end
  125. end
  126. end
  127. function LockChanged()
  128. if uis.MouseBehavior == Enum.MouseBehavior.LockCenter then
  129. db = false
  130. else
  131. if uis.MouseBehavior == Enum.MouseBehavior.Default or uis.MouseBehavior == Enum.MouseBehavior.LockCurrentPosition then
  132. db = true
  133. if not Sp_Db then
  134. if (CharHum.MoveDirection).Magnitude == 0 then
  135. stop()
  136. Create_Tween:Cancel()
  137. CharHum.WalkSpeed = 0
  138. anim_Table.Idle:Play()
  139. else
  140. stop()
  141. anim_Table.W:Play()
  142. end
  143. end
  144. end
  145. end
  146. end
  147.  
  148. --Events
  149. uis:GetPropertyChangedSignal('MouseBehavior'):Connect(LockChanged)
  150. uis.InputBegan:Connect(BeganKeys)
  151. CharHum:GetPropertyChangedSignal("MoveDirection"):Connect(Movement)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement