Advertisement
Marioplays

Bomb Spam

Jul 29th, 2024
558
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.99 KB | Source Code | 0 0
  1. local player = game.Players.LocalPlayer
  2. local workspace = game.Workspace
  3. local boxes = {}
  4. local spawnEnabled = true
  5. local gravityEnabled = true
  6. local collisionEnabled = true
  7. local loopTime = 1 -- Default loop time set to 1 second
  8. local running = true -- Flag to control the script's execution
  9.  
  10. -- Create GUI
  11. local screenGui = Instance.new("ScreenGui")
  12. screenGui.Parent = player:WaitForChild("PlayerGui")
  13.  
  14. -- Function to create buttons and return them for later reference
  15. local function createButton(name, position, onClick)
  16.     local button = Instance.new("TextButton")
  17.     button.Size = UDim2.new(0, 200, 0, 50)
  18.     button.Position = UDim2.new(0, position.X, 0, position.Y)
  19.     button.Text = name
  20.     button.Parent = screenGui
  21.     button.MouseButton1Click:Connect(onClick)
  22.     return button
  23. end
  24.  
  25. -- Function to create text input
  26. local function createTextBox(name, position, onSubmit)
  27.     local textBox = Instance.new("TextBox")
  28.     textBox.Size = UDim2.new(0, 200, 0, 50)
  29.     textBox.Position = UDim2.new(0, position.X, 0, position.Y)
  30.     textBox.Text = name -- Text is set to a description of the input
  31.     textBox.ClearTextOnFocus = false
  32.     textBox.Parent = screenGui
  33.     textBox.FocusLost:Connect(function(enterPressed)
  34.         if enterPressed then
  35.             onSubmit(textBox.Text)
  36.         end
  37.     end)
  38.     return textBox
  39. end
  40.  
  41. -- Create buttons and keep references
  42. local clearButton = createButton("Clear Boxes", Vector2.new(10, 10), function()
  43.     for _, box in ipairs(boxes) do
  44.         box:Destroy()
  45.     end
  46.     boxes = {}
  47. end)
  48.  
  49. local toggleGravityButton = createButton("Toggle Gravity", Vector2.new(10, 70), function()
  50.     gravityEnabled = not gravityEnabled
  51.     for _, box in ipairs(boxes) do
  52.         box.Anchored = not gravityEnabled
  53.     end
  54. end)
  55.  
  56. local toggleCollisionButton = createButton("Toggle Collision", Vector2.new(10, 130), function()
  57.     collisionEnabled = not collisionEnabled
  58.     for _, box in ipairs(boxes) do
  59.         box.CanCollide = collisionEnabled
  60.     end
  61. end)
  62.  
  63. local toggleSpawningButton = createButton("Toggle Spawning", Vector2.new(10, 190), function()
  64.     spawnEnabled = not spawnEnabled
  65. end)
  66.  
  67. local loopTimeBox = createTextBox("", Vector2.new(10, 250), function(text)
  68.     local number = tonumber(text)
  69.     if number and number > 0 then
  70.         loopTime = number
  71.     else
  72.         print("Invalid input. Please enter a positive number.")
  73.     end
  74. end)
  75.  
  76. local exitButton = createButton("Exit", Vector2.new(10, 310), function()
  77.     running = false
  78.     -- Remove all buttons and text boxes
  79.     clearButton:Destroy()
  80.     toggleGravityButton:Destroy()
  81.     toggleCollisionButton:Destroy()
  82.     toggleSpawningButton:Destroy()
  83.     loopTimeBox:Destroy()
  84.     exitButton:Destroy()
  85.     -- Optionally remove the GUI
  86.     screenGui:Destroy()
  87. end)
  88.  
  89. local function spawnBox()
  90.     if not spawnEnabled then return end
  91.     local box = Instance.new("Part")
  92.     box.Size = Vector3.new(5, 5, 5) -- Small box of size 5x5x5 studs
  93.     local playerPosition = player.Character and player.Character.PrimaryPart.Position or Vector3.new(0, 10, 0)
  94.     box.Position = playerPosition + Vector3.new(0, 10, 0) -- Spawn the box 10 studs above the player
  95.     box.Anchored = not gravityEnabled
  96.     box.CanCollide = collisionEnabled
  97.     box.BrickColor = BrickColor.new("Bright red")
  98.     box.Parent = workspace
  99.  
  100.     -- Add spawn sound
  101.     local spawnSound = Instance.new("Sound", box)
  102.     spawnSound.SoundId = "rbxassetid://4940109913"
  103.     spawnSound:Play()
  104.  
  105.     -- Add explosion after 2 seconds
  106.     delay(2, function()
  107.         local explosionSound = Instance.new("Sound", box)
  108.         explosionSound.SoundId = "rbxassetid://17567749644"
  109.         explosionSound:Play()
  110.  
  111.         local explosion = Instance.new("Explosion")
  112.         explosion.Position = box.Position
  113.         explosion.Parent = workspace
  114.  
  115.         -- Destroy the box after creating the explosion
  116.         box:Destroy()
  117.     end)
  118.  
  119.     table.insert(boxes, box)
  120. end
  121.  
  122. while running do
  123.     spawnBox()
  124.     wait(loopTime)
  125. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement