iOSdeveloper

Untitled

Jan 29th, 2025
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. local player = game:GetService("Players").LocalPlayer
  2. local playerGui = player:WaitForChild("PlayerGui")
  3. local inGameUI = playerGui:WaitForChild("InGameUI")
  4. local abilities = inGameUI.Bottom.Abilities
  5. local ability1 = abilities["1"]
  6.  
  7. local function copyAndChangeAbility()
  8. local copiedAbility = ability1:Clone()
  9. copiedAbility.Timer.Text = "Knuckle shoot"
  10. copiedAbility.Parent = abilities
  11. ability1:Destroy()
  12. end
  13.  
  14. copyAndChangeAbility()
  15.  
  16. local function onAbilityClick()
  17. local character = player.Character or player.CharacterAdded:Wait()
  18. local humanoid = character:WaitForChild("Humanoid")
  19. local animationId = "rbxassetid://122513708013347"
  20. local soundId = "rbxassetid://87838758006658"
  21.  
  22. local animation = Instance.new("Animation")
  23. animation.AnimationId = animationId
  24. local animationTrack = humanoid:LoadAnimation(animation)
  25.  
  26. animationTrack:Play()
  27.  
  28. local function fireRemoteAndPlaySoundHalfway()
  29. local animationLength = animationTrack.Length
  30. wait(animationLength / 2)
  31.  
  32. local sound = Instance.new("Sound")
  33. sound.SoundId = soundId
  34. sound.Parent = character
  35. sound:Play()
  36.  
  37. local args = {
  38. [1] = 200,
  39. }
  40. game:GetService("ReplicatedStorage").Packages.Knit.Services.BallService.RE.Shoot:FireServer(unpack(args))
  41. end
  42.  
  43. fireRemoteAndPlaySoundHalfway()
  44.  
  45. local function onAnimationEnded()
  46. animationTrack:Stop()
  47. end
  48.  
  49. animationTrack.Stopped:Connect(onAnimationEnded)
  50. end
  51.  
  52. ability1.MouseButton1Click:Connect(onAbilityClick)
  53.  
  54. local player = game:GetService("Players").LocalPlayer
  55. local playerGui = player:WaitForChild("PlayerGui")
  56. local inGameUI = playerGui:WaitForChild("InGameUI")
  57. local abilities = inGameUI.Bottom.Abilities
  58. local ability1 = abilities["1"]
  59.  
  60. -- Change the text of the Timer to "Knuckle shoot"
  61. ability1.Timer.Text = "Knuckle shoot"
  62.  
  63. -- Function to handle the click event
  64. local function onAbilityClick()
  65. local character = player.Character or player.CharacterAdded:Wait()
  66. local humanoid = character:WaitForChild("Humanoid")
  67. local animationId = "rbxassetid://122513708013347"
  68. local soundId = "rbxassetid://87838758006658"
  69.  
  70. local animation = Instance.new("Animation")
  71. animation.AnimationId = animationId
  72. local animationTrack = humanoid:LoadAnimation(animation)
  73.  
  74. animationTrack:Play()
  75.  
  76. local function fireRemoteAndPlaySoundHalfway()
  77. local animationLength = animationTrack.Length
  78. wait(animationLength / 2)
  79.  
  80. local sound = Instance.new("Sound")
  81. sound.SoundId = soundId
  82. sound.Parent = character
  83. sound:Play()
  84.  
  85. local args = {
  86. [1] = 200,
  87. }
  88. game:GetService("ReplicatedStorage").Packages.Knit.Services.BallService.RE.Shoot:FireServer(unpack(args))
  89. end
  90.  
  91. fireRemoteAndPlaySoundHalfway()
  92.  
  93. local function onAnimationEnded()
  94. -- You can add any additional logic here if needed
  95. end
  96.  
  97. animationTrack.Stopped:Connect(onAnimationEnded)
  98. end
  99.  
  100. -- Connect the click event to the ability button
  101. ability1.MouseButton1Click:Connect(onAbilityClick)
Advertisement
Add Comment
Please, Sign In to add comment