iOSdeveloper

Untitled

Jan 29th, 2025
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 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["2"]
  6.  
  7. -- Change the text of the Timer to "Knuckle shoot"
  8. ability2.Timer.Text = "Knuckle shoot"
  9.  
  10. -- Function to handle the click event
  11. local function onAbilityClick()
  12. local player = game.Players.LocalPlayer
  13. local character = player.Character or player.CharacterAdded:Wait()
  14. local humanoid = character:WaitForChild("Humanoid")
  15. local animationId = "rbxassetid://76950247429784"
  16. local soundId = "rbxassetid://76709779075029"
  17. local football = workspace:WaitForChild("Football")
  18. local teleportDistance = 26 -- Distance to check if the player is near the football
  19.  
  20. -- Load the animation
  21. local animation = Instance.new("Animation")
  22. animation.AnimationId = animationId
  23. local animationTrack = humanoid:LoadAnimation(animation)
  24.  
  25. -- Function to check distance and teleport
  26. local function checkDistanceAndTeleport()
  27. while true do
  28. wait(1) -- Check every second
  29. local distance = (character.HumanoidRootPart.Position - football.Position).magnitude
  30.  
  31. if distance <= teleportDistance then
  32. -- Teleport the player to the football's position
  33. character:SetPrimaryPartCFrame(football.CFrame)
  34.  
  35. -- Play the animation
  36. animationTrack:Play()
  37.  
  38. -- Play the sound
  39. local sound = Instance.new("Sound")
  40. sound.SoundId = soundId
  41. sound.Parent = character.HumanoidRootPart
  42. sound:Play()
  43.  
  44. -- Optional: Wait for the animation to finish before stopping the sound
  45. animationTrack.Stopped:Wait()
  46. sound:Destroy() -- Clean up the sound after playing
  47. break -- Exit the loop after teleporting
  48. end
  49. end
  50. end
  51.  
  52. -- Start checking distance
  53. checkDistanceAndTeleport()
  54.  
  55. local player = game.Players.LocalPlayer
  56. local character = player.Character or player.CharacterAdded:Wait()
  57. local humanoid = character:WaitForChild("Humanoid")
  58. local animationId = "rbxassetid://99916870664377"
  59. local soundId = "rbxassetid://70582458895457"
  60. local teleportDistance = 20 -- Distance to teleport forward
  61.  
  62. -- Load the animation
  63. local animation = Instance.new("Animation")
  64. animation.AnimationId = animationId
  65. local animationTrack = humanoid:LoadAnimation(animation)
  66.  
  67. -- Function to teleport forward
  68. local function teleportForward()
  69. -- Calculate the new position
  70. local newPosition = character.HumanoidRootPart.Position + (character.HumanoidRootPart.CFrame.LookVector * teleportDistance)
  71.  
  72. -- Teleport the player to the new position
  73. character:SetPrimaryPartCFrame(CFrame.new(newPosition))
  74.  
  75. -- Play the animation
  76. animationTrack:Play()
  77.  
  78. -- Play the sound
  79. local sound = Instance.new("Sound")
  80. sound.SoundId = soundId
  81. sound.Parent = character.HumanoidRootPart
  82. sound:Play()
  83.  
  84. -- Optional: Wait for the animation to finish before stopping the sound
  85. animationTrack.Stopped:Wait()
  86. sound:Destroy() -- Clean up the sound after playing
  87. end
  88.  
  89. -- Call the teleport function
  90. teleportForward()
  91. end
  92.  
  93. animationTrack.Stopped:Connect(onAnimationEnded)
  94. end
  95.  
  96. -- Connect the click event to the ability button
  97. ability2.MouseButton1Click:Connect(onAbilityClick)
Advertisement
Add Comment
Please, Sign In to add comment