iOSdeveloper

Untitled

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