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 ability1 = abilities["2"]
- -- Change the text of the Timer to "Knuckle shoot"
- ability2.Timer.Text = "Knuckle shoot"
- -- Function to handle the click event
- local function onAbilityClick()
- local player = game.Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoid = character:WaitForChild("Humanoid")
- 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()
- -- Optional: 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()
- local player = game.Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoid = character:WaitForChild("Humanoid")
- local animationId = "rbxassetid://99916870664377"
- local soundId = "rbxassetid://70582458895457"
- local teleportDistance = 20 -- Distance to teleport forward
- -- Load the animation
- local animation = Instance.new("Animation")
- animation.AnimationId = animationId
- local animationTrack = humanoid:LoadAnimation(animation)
- -- Function to teleport forward
- local function teleportForward()
- -- Calculate the new position
- local newPosition = character.HumanoidRootPart.Position + (character.HumanoidRootPart.CFrame.LookVector * teleportDistance)
- -- Teleport the player to the new position
- character:SetPrimaryPartCFrame(CFrame.new(newPosition))
- -- Play the animation
- animationTrack:Play()
- -- Play the sound
- local sound = Instance.new("Sound")
- sound.SoundId = soundId
- sound.Parent = character.HumanoidRootPart
- sound:Play()
- -- Optional: Wait for the animation to finish before stopping the sound
- animationTrack.Stopped:Wait()
- sound:Destroy() -- Clean up the sound after playing
- end
- -- Call the teleport function
- teleportForward()
- end
- animationTrack.Stopped:Connect(onAnimationEnded)
- end
- -- Connect the click event to the ability button
- ability2.MouseButton1Click:Connect(onAbilityClick)
Advertisement
Add Comment
Please, Sign In to add comment