Flic

Counter-Blox Bullet Tracers

Oct 11th, 2020 (edited)
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 KB | None | 0 0
  1. -- Counter-Blox Bullet Tracers | Open sourced.
  2.  
  3. local lifetime = 5 -- seconds
  4. local material = Enum.Material.ForceField
  5. local thickness = 0.1
  6. local color = Color3.fromRGB(0, 120, 255)
  7.  
  8. local mt = getrawmetatable(game)
  9. local old = mt.__namecall
  10. local lp = game:GetService("Players").LocalPlayer
  11. local rs = game:GetService("RunService").RenderStepped
  12. local lasthittick = tick()
  13. local this = script
  14. setreadonly(mt, false)
  15.  
  16. function createBeam(p1, p2)
  17.     local beam = Instance.new("Part", workspace)
  18.     beam.Anchored = true
  19.     beam.CanCollide = false
  20.     beam.Material = material
  21.     beam.Color = color
  22.     beam.Size = Vector3.new(thickness, thickness, (p1 - p2).magnitude)
  23.     beam.CFrame = CFrame.new(p1, p2) * CFrame.new(0, 0, -beam.Size.Z / 2)
  24.     return beam
  25. end
  26.  
  27. mt.__namecall = newcclosure(function(self, ...)
  28.     local args = {...}
  29.     if getnamecallmethod() == "FireServer" and self.Name == "HitPart" and tick() - lasthittick > 0.005 then
  30.         lasthittick = tick()
  31.         spawn(function()
  32.             local beam = createBeam(lp.Character.Head.CFrame.p, args[2])
  33.             for i = 1, 60 * lifetime do
  34.                 rs:Wait()
  35.                 beam.Transparency = i / (60 * lifetime)
  36.             end
  37.             beam:Destroy()
  38.         end)
  39.     end
  40.     return old(self, ...)
  41. end)
Add Comment
Please, Sign In to add comment