Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game:GetService("Players").LocalPlayer
- local playerGui = player:WaitForChild("PlayerGui")
- local inGameUI = playerGui:WaitForChild("InGameUI")
- local abilities = inGameUI.Bottom.Abilities
- local ability2 = abilities["2"]
- -- Function to copy and change the ability
- local function copyAndChangeAbility()
- local copiedAbility = ability2:Clone()
- copiedAbility.Timer.Text = "Direct Dribble" -- Set the text for the ability
- copiedAbility.Parent = abilities
- ability2:Destroy() -- Remove the original ability
- end
- copyAndChangeAbility()
- -- Function to handle the click event for the ability
- local function onAbilityClick()
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoid = character:WaitForChild("Humanoid")
- -- Animation and sound IDs
- local animationId = "rbxassetid://76950247429784"
- local soundId = "rbxassetid://76709779075029"
- local football = workspace:WaitForChild("Football")
- local teleportDistance = 26 -- Distance to check if the player is near the football
- -- Load the animation
- local animation = Instance.new("Animation")
- animation.AnimationId = animationId
- local animationTrack = humanoid:LoadAnimation(animation)
- -- Function to check distance and teleport
- local function checkDistanceAndTeleport()
- while true do
- wait(1) -- Check every second
- local distance = (character.HumanoidRootPart.Position - football.Position).magnitude
- if distance <= teleportDistance then
- -- Teleport the player to the football's position
- character:SetPrimaryPartCFrame(football.CFrame)
- -- Play the animation
- animationTrack:Play()
- -- Play the sound
- local sound = Instance.new("Sound")
- sound.SoundId = soundId
- sound.Parent = character.HumanoidRootPart
- sound:Play()
- -- Wait for the animation to finish before stopping the sound
- animationTrack.Stopped:Wait()
- sound:Destroy() -- Clean up the sound after playing
- break -- Exit the loop after teleporting
- end
- end
- end
- -- Start checking distance
- checkDistanceAndTeleport()
- -- Teleport forward function
- local function teleportForward()
- local forwardDistance = 20 -- Distance to teleport forward
- local newPosition = character.HumanoidRootPart.Position + (character.HumanoidRootPart.CFrame.LookVector * forwardDistance)
- -- Teleport the player to the new position
- character:SetPrimaryPartCFrame(CFrame.new(newPosition))
- -- Play the forward teleport animation
- local forwardAnimationId = "rbxassetid://99916870664377"
- local forwardAnimation = Instance.new("Animation")
- forwardAnimation.AnimationId = forwardAnimationId
- local forwardAnimationTrack = humanoid:LoadAnimation(forwardAnimation)
- forwardAnimationTrack:Play()
- -- Play the sound for forward teleport
- local forwardSoundId = "rbxassetid://70582458895457"
- local forwardSound = Instance.new("Sound")
- forwardSound.SoundId = forwardSoundId
- forwardSound.Parent = character.HumanoidRootPart
- forwardSound:Play()
- -- Wait for the animation to finish before stopping the sound
- forwardAnimationTrack.Stopped:Wait()
- forwardSound:Destroy() -- Clean up the sound after playing
- end
- -- Call the teleport forward function
- teleportForward()
- end
- -- Connect the click event to the ability button
- ability2.MouseButton1Click:Connect(onAbilityClick)
- local player = game:GetService("Players").LocalPlayer
- local playerGui = player:WaitForChild("PlayerGui")
- local inGameUI = playerGui:WaitForChild("InGameUI")
- local abilities = inGameUI.Bottom.Abilities
- local ability2 = abilities["2"] -- Ensure this is the correct ability reference
- -- Change the text of the Timer to "Direct Dribble"
- ability2.Timer.Text = "Direct Dribble"
- -- Function to handle the click event
- local function onAbilityClick()
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoid = character:WaitForChild("Humanoid")
- -- Animation and sound IDs for the teleport to football
- local animationId = "rbxassetid://76950247429784"
- local soundId = "rbxassetid://76709779075029"
- local football = workspace:WaitForChild("Football")
- local teleportDistance = 26 -- Distance to check if the player is near the football
- -- Load the animation
- local animation = Instance.new("Animation")
- animation.AnimationId = animationId
- local animationTrack = humanoid:LoadAnimation(animation)
- -- Function to check distance and teleport to the football
- local function checkDistanceAndTeleport()
- while true do
- wait(1) -- Check every second
- local distance = (character.HumanoidRootPart.Position - football.Position).magnitude
- if distance <= teleportDistance then
- -- Teleport the player to the football's position
- character:SetPrimaryPartCFrame(football.CFrame)
- -- Play the animation
- animationTrack:Play()
- -- Play the sound
- local sound = Instance.new("Sound")
- sound.SoundId = soundId
- sound.Parent = character.HumanoidRootPart
- sound:Play()
- -- Wait for the animation to finish before stopping the sound
- animationTrack.Stopped:Wait()
- sound:Destroy() -- Clean up the sound after playing
- break -- Exit the loop after teleporting
- end
- end
- end
- -- Start checking distance
- checkDistanceAndTeleport()
- -- Teleport forward function
- local function teleportForward()
- local forwardAnimationId = "rbxassetid://99916870664377"
- local forwardSoundId = "rbxassetid://70582458895457"
- local forwardDistance = 20 -- Distance to teleport forward
- -- Load the forward animation
- local forwardAnimation = Instance.new("Animation")
- forwardAnimation.AnimationId = forwardAnimationId
- local forwardAnimationTrack = humanoid:LoadAnimation(forwardAnimation)
- -- Calculate the new position
- local newPosition = character.HumanoidRootPart.Position + (character.HumanoidRootPart.CFrame.LookVector * forwardDistance)
- -- Teleport the player to the new position
- character:SetPrimaryPartCFrame(CFrame.new(newPosition))
- -- Play the forward animation
- forwardAnimationTrack:Play()
- -- Play the sound for forward teleport
- local forwardSound = Instance.new("Sound")
- forwardSound.SoundId = forwardSoundId
- forwardSound.Parent = character.HumanoidRootPart
- forwardSound:Play()
- -- Wait for the animation to finish before stopping the sound
- forwardAnimationTrack.Stopped:Wait()
- forwardSound:Destroy() -- Clean up the sound after playing
- end
- -- Call the teleport forward function
- teleportForward()
- end
- -- Connect the click event to the ability button
- ability2.MouseButton1Click:Connect(onAbilityClick)
Advertisement
Add Comment
Please, Sign In to add comment