Advertisement
Guest User

Combat Module V1

a guest
Nov 18th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. local module = {}
  2. rs = game:GetService('RunService')
  3. function lerpcframe(object, endcf, step)
  4. local d = coroutine.wrap(function()
  5. local save = object.CFrame
  6. for i=0,1, step do
  7. wait()
  8. object.CFrame = save:lerp(endcf, i)
  9. end
  10. end)
  11. d()
  12. end
  13. module.startcombat = function(npc, player)
  14. print("yup")
  15. player.HumanoidRootPart.Anchored = true
  16. player.Humanoid.WalkSpeed = 0
  17. npc.Humanoid.WalkSpeed = 0
  18. npc.HumanoidRootPart.Anchored = true
  19. game.ReplicatedStorage.StartCombat:FireClient(game.Players[player.Name], npc, 2)
  20. lerpcframe(player.HumanoidRootPart, CFrame.new(player.HumanoidRootPart.Position, npc.HumanoidRootPart.Position), .025)
  21. lerpcframe(npc.HumanoidRootPart, CFrame.new(npc.HumanoidRootPart.Position, player.HumanoidRootPart.Position), .025)
  22. wait(2)
  23. local fire1 = Instance.new('Fire')
  24. fire1.Color = Color3.new(255,255,255)
  25. local circle1 = game.ReplicatedStorage.range:Clone()
  26. circle1.Parent = game.Lighting
  27. local circle2 = game.ReplicatedStorage.range:Clone()
  28. local beam = Instance.new('Part', game.Workspace)
  29. beam.Transparency = 0
  30. beam.Material = "Neon"
  31. beam.Size = Vector3.new(1,1,.1)
  32. beam.Anchored = true
  33. beam.CanCollide = false
  34. beam.Color = Color3.fromRGB(0,200,180)
  35. local beam2 = beam:Clone()
  36. local beam3 = beam:Clone()
  37. local beam4 = beam:Clone()
  38. local beam5 = beam:Clone()
  39. local beam6 = beam:Clone()
  40. beam2.Parent = game.Workspace
  41. beam3.Parent = game.Workspace
  42. beam4.Parent = game.Workspace
  43. beam5.Parent = game.Workspace
  44. beam6.Parent = game.Workspace
  45. local tables = {beam, beam2, beam3, beam4, beam5, beam6}
  46. local dist = (npc.HumanoidRootPart.Position - player.HumanoidRootPart.Position).magnitude
  47. --fire1.Parent = npc.HumanoidRootPart
  48. circle1.Parent = game.Workspace
  49. circle1.CFrame = npc.HumanoidRootPart.CFrame
  50. local pos = npc.HumanoidRootPart.Position:lerp(player.HumanoidRootPart.Position, .5)
  51. local pos1 = pos + (npc.HumanoidRootPart.CFrame.rightVector * (dist/4))
  52. local pos2 = pos + (npc.HumanoidRootPart.CFrame.rightVector * -(dist/4))
  53. local dist2 = (npc.HumanoidRootPart.Position - pos1).magnitude
  54. local dist3 = (pos1 - pos2).magnitude
  55. for i = 1, 100, .8 do
  56. beam.Size = Vector3.new(1,1, dist * (i/100))
  57. beam.CFrame = CFrame.new(npc.HumanoidRootPart.Position, player.HumanoidRootPart.Position)
  58. beam.CFrame = beam.CFrame + (beam.CFrame.lookVector * (beam.Size.Z/2))
  59. beam2.Size = Vector3.new(1,1, dist2 * (i/100))
  60. beam3.Size = Vector3.new(1,1, dist2 * (i/100))
  61. beam4.Size = Vector3.new(1,1, dist2 * (i/100))
  62. beam5.Size = Vector3.new(1,1, dist2 * (i/100))
  63. beam2.CFrame = CFrame.new(npc.HumanoidRootPart.Position, pos1)
  64. beam3.CFrame = CFrame.new(npc.HumanoidRootPart.Position, pos2)
  65. beam4.CFrame = CFrame.new(player.HumanoidRootPart.Position, pos1)
  66. beam5.CFrame = CFrame.new(player.HumanoidRootPart.Position, pos2)
  67. beam2.CFrame = beam2.CFrame + (beam2.CFrame.lookVector * (beam2.Size.Z/2))
  68. beam3.CFrame = beam3.CFrame + (beam3.CFrame.lookVector * (beam3.Size.Z/2))
  69. beam4.CFrame = beam4.CFrame + (beam4.CFrame.lookVector * (beam4.Size.Z/2))
  70. beam5.CFrame = beam5.CFrame + (beam5.CFrame.lookVector * (beam5.Size.Z/2))
  71. for a,b in pairs(tables) do
  72. b.CFrame = b.CFrame - Vector3.new(0,2,0)
  73. end
  74. rs.Stepped:Wait()
  75. end
  76. for i=0,1,.1 do
  77. for a,b in pairs(tables) do
  78. if b ~= beam then
  79. b.Transparency = i
  80. end
  81. end
  82. wait()
  83. end
  84. for a,b in pairs(tables) do
  85. if b ~= beam then
  86. b:Destroy()
  87. end
  88. end
  89. fire2 = fire1:Clone()
  90. -- fire2.Parent = player.HumanoidRootPart
  91. circle2.Parent = game.Workspace
  92. circle2.CFrame = player.HumanoidRootPart.CFrame
  93. end
  94.  
  95.  
  96. return module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement