Advertisement
mr2meows

grenade

Mar 17th, 2023 (edited)
434
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 1 0
  1. local tool = Instance.new("Tool",owner.Backpack)
  2. local handle = Instance.new("Part",tool)
  3. handle.Name = "Handle"
  4. tool.Name = "grenade"
  5. handle.Shape = "Ball"
  6. handle.Size = Vector3.new(1,1,1)
  7. handle.BrickColor = BrickColor.new("Sea green")
  8. handle.Anchored = false
  9. local boom = Instance.new("Sound",handle)
  10. boom.SoundId = "rbxassetid://9114840785"
  11. local clik = Instance.new("Sound",handle)
  12. clik.SoundId = "rbxassetid://9116545076"
  13. local clunk = Instance.new("Sound",handle)
  14. clunk.SoundId = "rbxassetid://9116260154"
  15. function launch()
  16.     clik:Play()
  17.     local minors = true
  18.     tool.Enabled = false
  19.     local grenade = Instance.new("Part",workspace)
  20.     grenade.Size = Vector3.new(1,1,1)
  21.     grenade.Shape = "Ball"
  22.     grenade.BrickColor = BrickColor.new("Sea green")
  23.     grenade.CanCollide = true
  24.     grenade.Anchored = false
  25.     local spawnPosition = (handle.CFrame * CFrame.new(0, 0, -5)).p
  26.     grenade.CFrame = CFrame.new(spawnPosition) --NOTE: This must be done before assigning Parent
  27.     grenade.Velocity = tool.Parent.Head.CFrame.lookVector * 64
  28.     --Instance.new('BodyForce', grenade).Force = Vector3.new(0, grenade:GetMass() * workspace.Gravity, 0)
  29.     grenade.Touched:Connect(function()
  30.         if minors == true then
  31.             clunk:Play()
  32.             minors = false
  33.             wait(.5)
  34.             grenade.Anchored = true
  35.             wait(1.5)
  36.             local exploder = Instance.new("Explosion")
  37.             exploder.Position = grenade.Position
  38.             exploder.Parent = workspace
  39.             boom:Play()
  40.             grenade:Destroy()
  41.             minors = true
  42.             tool.Enabled = true
  43.         end
  44.     end)
  45. end
  46. tool.Activated:Connect(launch)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement