Guest User

Untitled

a guest
Jan 3rd, 2025
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1.  
  2.  
  3. -- variables
  4.  
  5. local CanDamage = false -- variable for wether it can damage or no
  6. local M1 = 1 --what M1 animation it will be
  7. local CanAttack = true --variable for wether it can attack or no. so basically a cooldown
  8.  
  9. -- get stuff
  10.  
  11. local player = game.Players.LocalPlayer
  12. local character = player.Character or player.CharacterAdded:wait()
  13. if character == nil then
  14. player.CharacterAdded:Wait()
  15. character = player.Character
  16. end
  17. local M1HITBOX = character:WaitForChild("Right Arm") --hitboxes
  18. local M2HITBOX = character:WaitForChild("Left Arm")
  19. local M3HITBOX = character:WaitForChild("Left Leg")
  20. local hum = character:WaitForChild("Humanoid")
  21. local UIS = game:GetService("UserInputService")
  22. local StunValue = character:WaitForChild("StunValue")
  23.  
  24.  
  25. local Animtable = {
  26. ["M1"] = hum:LoadAnimation(game.ReplicatedStorage.Anims.Core.M1s.M1),
  27. ["M2"] = hum:LoadAnimation(game.ReplicatedStorage.Anims.Core.M1s.M2),
  28. ["M3"] = hum:LoadAnimation(game.ReplicatedStorage.Anims.Core.M1s.M3),
  29. ["M4"] = hum:LoadAnimation(game.ReplicatedStorage.Anims.Core.M1s.M4)
  30. }
  31.  
  32. Animtable.M1.Looped = false
  33. Animtable.M2.Looped = false
  34. Animtable.M3.Looped = false
  35. Animtable.M4.Looped = false
  36.  
  37. local CharValue = character:WaitForChild("CharValue")
  38.  
  39.  
  40. local M1Remote = game.ReplicatedStorage.Remotes.Core.M1sRemote -- getting remote
  41.  
  42.  
  43. local function onInputBegan(input, gameProcessed)
  44. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  45. print("M1 Value is", M1)
  46. print("CanAttack Is", CanAttack)
  47. print("CanDamage is", CanDamage)
  48. if CanAttack == true and StunValue.Value == false then -- activates if theres no cooldown and your not stunned
  49. CanAttack = false
  50. print("M1ed")
  51. print("M1 Value is", M1)
  52. print("CanAttack Is", CanAttack)
  53. print("CanDamage is", CanDamage)
  54. if M1 == 1 then
  55. print("m1 is 1 now :D")
  56. Animtable.M1:Play()
  57. print("played animation")
  58. StunValue.Value = true
  59. CanAttack = false
  60. task.wait(0.283)
  61. if CanDamage == false then
  62. CanDamage = true
  63.  
  64. M1Remote:FireServer(character, hum)
  65. --print("M1 Touched")
  66.  
  67. end
  68. Animtable.M1.Stopped:Connect(function()
  69. StunValue.Value = false
  70. CanAttack = true
  71. print("M1Stopped")
  72. print("Can Attack is", CanAttack)
  73. M1 = 2
  74. CanDamage = false
  75. end)
  76. end
  77.  
  78. if M1 == 2 then
  79. Animtable.M2:Play()
  80. StunValue.Value = true
  81. CanAttack = false
  82. task.wait(0.267)
  83. if CanDamage == false then
  84. CanDamage = true
  85. M1Remote:FireServer(character, hum)
  86. --print("m2 touched")
  87.  
  88. end
  89. Animtable.M2.Stopped:Connect(function()
  90. StunValue.Value = false
  91. CanAttack = true
  92. M1 = 3
  93. CanDamage = false
  94. end)
  95. end
  96.  
  97. if M1 == 3 then
  98. Animtable.M3:Play()
  99. StunValue.Value = true
  100. CanAttack = false
  101. task.wait(0.267)
  102. if CanDamage == false then
  103. CanDamage = true
  104. M1Remote:FireServer(character, hum)
  105. end
  106. --tells server that it got hit
  107. end
  108. Animtable.M3.Stopped:Connect(function()
  109. StunValue.Value = false
  110. CanAttack = true
  111. M1 = 4
  112. CanDamage = false
  113. end)
  114.  
  115. if M1 == 4 then
  116. Animtable.M4:Play()
  117. StunValue.Value = true
  118. CanAttack = false--changes walkspeed
  119. task.wait(.3) --waits until the Hit part of the animation
  120. if CanDamage == false then
  121. CanDamage = true
  122. M1Remote:FireServer(character, hum)
  123. end
  124. --tells server that it got hit
  125. end
  126. Animtable.M4.Stopped:Connect(function()
  127. StunValue.Value = false--does smthn when the animation is done
  128. task.wait(2) --cooolddown
  129. --print(CanAttack)
  130. --print(M1)
  131. --print(CanDamage)
  132. CanAttack = true
  133. M1 = 1 --resets back to first M1
  134. CanDamage = false
  135. end)
  136. end
  137. end
  138. end
  139.  
  140. game:GetService("UserInputService").InputBegan:Connect(onInputBegan)
  141.  
  142.  
  143.  
  144.  
  145.  
  146. M1Remote.OnClientEvent:Connect(function(Eplr, Ehum)
  147. print("Recieved server to client")
  148. end)
  149.  
  150.  
  151.  
  152.  
Advertisement
Add Comment
Please, Sign In to add comment