KashTheKingYT

Powerup Script 1

Nov 7th, 2021
1,350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. local part = script.Parent
  2. local powerupSpeed = 20
  3. local debounce = false
  4. local regularWalkspeed = game.StarterPlayer.CharacterWalkSpeed
  5. local timer = 5
  6. local particleEmitter = part.ParticleEmitter
  7. local soundEffect = part.SoundEffect
  8.  
  9. part.Touched:Connect(function(hit)
  10.     if hit.Parent:FindFirstChild("Humanoid") and debounce == false and not hit.Parent:FindFirstChild("Powerup")
  11.     then
  12.         debounce = true
  13.         local powerup = Instance.new("StringValue", hit.Parent)
  14.         powerup.Name = "Powerup"
  15.         part.Transparency = 1
  16.         soundEffect:Play()
  17.         local char = hit.Parent
  18.         local humanoid = char:WaitForChild("Humanoid")
  19.         humanoid.WalkSpeed = powerupSpeed
  20.         particleEmitter.Parent = char.HumanoidRootPart
  21.         wait(timer)
  22.         humanoid.WalkSpeed = regularWalkspeed
  23.         debounce = false
  24.         particleEmitter:Destroy()
  25.         powerup:Destroy()
  26.         part:Destroy()
  27.     end
  28. end)
Advertisement
Add Comment
Please, Sign In to add comment