iOSdeveloper

Untitled

Jan 29th, 2025 (edited)
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 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. ability1.Timer.Text = "Knuckle shoot"
  61.  
  62. local function onAbilityClick()
  63. local character = player.Character or player.CharacterAdded:Wait()
  64. local hasBallValue = character:FindFirstChild("Values") and character.Values:FindFirstChild("HasBall")
  65.  
  66. if hasBallValue and hasBallValue.Value then
  67. local humanoid = character:WaitForChild("Humanoid")
  68. local animationId = "rbxassetid://122513708013347"
  69. local soundId = "rbxassetid://87838758006658"
  70.  
  71. local animation = Instance.new("Animation")
  72. animation.AnimationId = animationId
  73. local animationTrack = humanoid:LoadAnimation(animation)
  74.  
  75. animationTrack:Play()
  76.  
  77. local function fireRemoteAndPlaySoundHalfway()
  78. local animationLength = animationTrack.Length
  79. wait(animationLength / 2)
  80.  
  81. local sound = Instance.new("Sound")
  82. sound.SoundId = soundId
  83. sound.Parent = character
  84. sound:Play()
  85. sound.Ended:Connect(function() sound:Destroy() end) -- Clean up sound after it finishes
  86.  
  87. local args = {
  88. [1] = 200,
  89. }
  90. game:GetService("ReplicatedStorage").Packages.Knit.Services.BallService.RE.Shoot:FireServer(unpack(args))
  91. end
  92.  
  93. fireRemoteAndPlaySoundHalfway()
  94.  
  95. local function onAnimationEnded()
  96. -- You can add any logic here if needed when the animation ends
  97. end
  98.  
  99. animationTrack.Stopped:Connect(onAnimationEnded)
  100. else
  101. print("You do not have the ball to use this ability.")
  102. end
  103. end
  104.  
  105. ability1.MouseButton1Click:Connect(onAbilityClick)
Advertisement
Add Comment
Please, Sign In to add comment