qsenko1

BoucePadScript

Sep 27th, 2021
1,027
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local TweenService = game:GetService("TweenService")
  2. local Players = game:GetService("Players")
  3. local player = Players.LocalPlayer
  4.  
  5. local BouncePadOpenTweenInfo = TweenInfo.new(0.4)
  6. local BouncePadCloseTweenInfo = TweenInfo.new(0.2)
  7.  
  8. local BounceSound1 = game.Workspace.BouncePadLevel["Bounce Pad1"].Plate.PadSoundEffect
  9. local BounceSound2 = game.Workspace.BouncePadLevel["Bounce Pad2"].Plate.PadSoundEffect
  10. local BounceSound3 = game.Workspace.BouncePadLevel["Bounce Pad3"].Plate.PadSoundEffect
  11. local BounceSound4 = game.Workspace.BouncePadLevel["Bounce Pad4"].Plate.PadSoundEffect
  12. local BounceSound5 = game.Workspace.BouncePadLevel["Bounce Pad5"].Plate.PadSoundEffect
  13.  
  14. local BouncePads = game.Workspace:WaitForChild("BouncePadLevel")
  15.  
  16. local function BouncepadEffect(char, BouncePadModel)
  17.     local HumanoidRootPart = char.PrimaryPart
  18.     if HumanoidRootPart ~= nil then
  19.         local TempBounceInProgress = BouncePadModel:WaitForChild("BounceInProgress")
  20.         if TempBounceInProgress.Value == false then
  21.             TempBounceInProgress.Value = true
  22.            
  23.             local Pad = BouncePadModel.PrimaryPart
  24.             Pad.CanCollide = false
  25.            
  26.             local BounceVelocity = Instance.new("BodyVelocity")
  27.             BounceVelocity.Name = "BounceVelocity"
  28.             BounceVelocity.Velocity = Vector3.new(0, BouncePadModel:WaitForChild("Power").Value, 0)
  29.             BounceVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  30.             BounceVelocity.P = math.huge
  31.             BounceVelocity.Parent = HumanoidRootPart
  32.            
  33.             spawn(function()
  34.                 wait(BouncePadModel:WaitForChild("Time").Value)
  35.                 BounceVelocity:Destroy()
  36.             end)
  37.            
  38.             local CoilMesh = BouncePadModel:WaitForChild("Coil"):WaitForChild("Mesh")
  39.            
  40.             local TempTween1 = TweenService:Create(CoilMesh, BouncePadOpenTweenInfo, {Scale = Vector3.new(CoilMesh.Scale.X, CoilMesh.Scale.Y, CoilMesh.Scale.Z + 2)})
  41.             local TempTween2 = TweenService:Create(Pad, BouncePadOpenTweenInfo, {CFrame = Pad.CFrame + Vector3.new(0,4,0)})
  42.             TempTween1:Play()
  43.             TempTween2:Play()
  44.            
  45.             wait(0,1)
  46.             Pad.CanCollide = true
  47.             wait(0.4)
  48.            
  49.             local TempTween3 = TweenService:Create(CoilMesh, BouncePadCloseTweenInfo, {Scale = Vector3.new(CoilMesh.Scale.X, CoilMesh.Scale.Y, CoilMesh.Scale.Z - 2)})
  50.             local TempTween4 = TweenService:Create(Pad, BouncePadCloseTweenInfo, {CFrame = Pad.CFrame - Vector3.new(0,4,0)})
  51.            
  52.             TempTween3:Play()
  53.             TempTween4:Play()
  54.             TempTween4.Completed:Wait()
  55.             TempBounceInProgress.Value = false
  56.         end
  57.     end
  58. end
  59.  
  60. for _,BouncePad in pairs(BouncePads:GetChildren()) do
  61.     BouncePad.PrimaryPart.Touched:Connect(function(hit)
  62.         local char = hit.Parent
  63.         if char ~= nil then
  64.             local TempPlayer = Players:GetPlayerFromCharacter(char)
  65.             if TempPlayer ~= nil and player == TempPlayer then
  66.                 BouncepadEffect(char, BouncePad)                   
  67.             end
  68.         end
  69.     end)
  70. end
RAW Paste Data