Advertisement
Parallaxox

Explosion on Key Press

Jan 3rd, 2024
718
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. --https://youtu.be/Ut8uWXHiucU
  2. local UserInputService = game:GetService("UserInputService")
  3. local player = game.Players.LocalPlayer
  4. local mouse = player:GetMouse()
  5.  
  6. local keyHeld = false
  7.  
  8. function KeyDown(input, gameProcessed)
  9.     if input.KeyCode == Enum.KeyCode.E then
  10.         keyHeld = true
  11.         while keyHeld do
  12.             -- Create an explosion at the mouse's position
  13.             local explosion = Instance.new("Explosion", game.Workspace)
  14.             explosion.Position = Vector3.new(mouse.Hit.p.X, mouse.Hit.p.Y, mouse.Hit.p.Z)
  15.  
  16.             -- Wait a short time before creating the next explosion
  17.             wait(0.5) -- Adjust the time for explosion frequency as needed
  18.         end
  19.     end
  20. end
  21.  
  22. function KeyUp(input, gameProcessed)
  23.     if input.KeyCode == Enum.KeyCode.E then
  24.         keyHeld = false
  25.     end
  26. end
  27.  
  28. UserInputService.InputBegan:Connect(KeyDown)
  29. UserInputService.InputEnded:Connect(KeyUp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement