Advertisement
Anukun_Lucifer

GunFireScript

Apr 10th, 2023
2,654
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | Gaming | 1 0
  1. local rs = game:GetService("ReplicatedStorage")
  2. local debris = game:GetService("Debris")
  3. local gun = script.Parent
  4. local gunsound = script.Parent["Gun Shot"]
  5. local damage = 20
  6.  
  7. gun.Activated:Connect(function(hitfire)
  8.     local bullet = game.ReplicatedStorage.Bullet:Clone()
  9.     bullet.Parent = game.Workspace
  10.     bullet.CFrame = script.Parent.Fire.CFrame
  11.     bullet.Velocity = script.Parent.Fire.CFrame.LookVector * 400
  12.     gunsound:Play()
  13.     debris:AddItem(bullet,3)
  14.    
  15.     bullet.Touched:Connect(function(hitdamage)
  16.         if hitdamage.Parent:FindFirstChild("Humanoid") and hitdamage.Parent ~= gun.Parent then
  17.             local enemy = hitdamage.Parent
  18.             local bloodsound = script.Parent["Big Blood Damage 1"]
  19.             enemy.Humanoid.Health -= damage
  20.             bloodsound:Play()
  21.             bullet:Destroy()
  22.         end
  23.     end)
  24. end)
Tags: Roblox Gun
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement