Advertisement
HowToRoblox

SmokeGrenadeServer

May 6th, 2021
1,824
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. local grenade = script.Parent
  2.  
  3. local re = grenade:WaitForChild("ThrowRE")
  4.  
  5. local cooldown = false
  6.  
  7.  
  8. local ps = game:GetService("PhysicsService")
  9. ps:CreateCollisionGroup("Grenade")
  10. ps:CreateCollisionGroup("Character")
  11. ps:CollisionGroupSetCollidable("Character", "Grenade", false)
  12.  
  13.  
  14.  
  15. re.OnServerEvent:Connect(function(plr, mouseHit)
  16.    
  17.     if cooldown then return end
  18.     cooldown = true
  19.        
  20.    
  21.     local grenadeCopy = grenade.Handle:Clone()
  22.    
  23.    
  24.     for i, descendant in pairs(plr.Character:GetDescendants()) do
  25.        
  26.         if descendant:IsA("BasePart") then ps:SetPartCollisionGroup(descendant, "Character") end
  27.     end
  28.    
  29.     ps:SetPartCollisionGroup(grenadeCopy, "Grenade")
  30.    
  31.    
  32.     local velocity = (mouseHit.Position - Vector3.new(0, -game.Workspace.Gravity * 0.3, 0))
  33.  
  34.     grenadeCopy.Velocity = velocity
  35.     grenadeCopy.CanCollide = true
  36.     grenadeCopy.Parent = workspace
  37.    
  38.    
  39.     grenade.Handle.Transparency = 1
  40.    
  41.    
  42.     wait(3)
  43.    
  44.     grenadeCopy.Smoke.Enabled = true
  45.     grenadeCopy.Explode:Play()
  46.    
  47.     wait(grenadeCopy.Explode.TimeLength)
  48.     grenadeCopy:Destroy()
  49.     grenade.Handle.Transparency = 0
  50.     cooldown = false
  51. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement