Advertisement
Upscalefanatic34

Rayy

May 23rd, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. me = game.Players.Upscalegaming
  2.  
  3. if script.Parent.className ~= "HopperBin" then
  4. h = Instance.new("HopperBin")
  5. h.Parent = me.Backpack
  6. h.Name = "RayCast"
  7. script.Parent = h
  8. end
  9.  
  10. bin = script.Parent
  11.  
  12. function GetPhysicsChildren(path)
  13. local objects = {}
  14. for _, children in pairs(path:GetChildren()) do
  15. if children.className == "Part" or children.className == "Seat" or children.className == "WedgePart" or children.className == "TrussPart" or children.className == "VehicleSeat" or children.className == "SkateboardPlatform" then
  16. table.insert(objects, children)
  17. end
  18. if #children:GetChildren() > 0 then
  19. local objects2 = GetPhysicsChildren(children)
  20. for i = 1, #objects2 do
  21. table.insert(objects, objects2[i])
  22. end
  23. end
  24. end
  25. return objects
  26. end
  27.  
  28.  
  29. function RayCast(pos1, pos2, maxDistance)
  30. local pos0 = pos1
  31. local objects = GetPhysicsChildren(game:GetService("Workspace"))
  32. for distance = 1, maxDistance, 1 do
  33. pos0 = (CFrame.new(pos1, pos2) * CFrame.new(0, 0, -distance)).p
  34. for _, children in pairs(objects) do
  35. if children.Name ~= "Bullet Trail" then
  36. --if (children.CanCollide and children.Transparency > 0) or (game:GetService("Players"):getPlayerFromCharacter(children.Parent)) then
  37. local pos3 = children.CFrame:pointToObjectSpace(pos0)
  38. if pos3.x > -(children.Size.x / 2) and pos3.x < (children.Size.x / 2) and pos3.y > -(children.Size.y / 2) and pos3.y < (children.Size.y / 2) and pos3.z > -(children.Size.z / 2) and pos3.z < (children.Size.z / 2) then
  39. return pos0, children
  40. end
  41. end
  42. end
  43. end
  44. return pos0, nil
  45. end
  46.  
  47.  
  48. function fire(startPoint, endPoint)
  49. if startPoint == nil then return end
  50. if endPoint == nil then return end
  51. local pos, hit = RayCast(startPoint, endPoint, 60)
  52. local tr = Instance.new("Part")
  53. tr.Name = "Bullet Trail"
  54. tr.Anchored = true
  55. tr.formFactor = 0
  56. tr.TopSurface = 0
  57. tr.BottomSurface = 0
  58. tr.Size = Vector3.new(1,1,1)
  59. tr.BrickColor = BrickColor.new("Bright yellow")
  60. tr.CanCollide = false
  61. tr.CFrame = CFrame.new((startPoint + pos)/2, pos)
  62. tr.Parent = workspace
  63. local mesh = Instance.new("BlockMesh",tr)
  64. mesh.Scale = Vector3.new(0.1,0.1,(startPoint - pos).magnitude)
  65. if hit ~= nil then
  66. local hum = hit.Parent:findFirstChild("Humanoid")
  67. if hum ~= nil then
  68. hum.Health = hum.Health - 13
  69. end
  70. end
  71. coroutine.resume(coroutine.create(function()
  72. for i=0,1,0.15 do
  73. wait()
  74. tr.Transparency = i
  75. end
  76. tr:remove()
  77. end))
  78. end
  79.  
  80. function select(mouse)
  81. mouse.Button1Down:connect(function()
  82. fire(me.Character.Torso.Position, mouse.Hit.p)
  83. end)
  84. end
  85.  
  86.  
  87. bin.Selected:connect(select)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement