Advertisement
D_rawest16

Untitled

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