codemen

Brown spear script [roblox]

Nov 17th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.96 KB | None | 0 0
  1. local plr = game:service'Players'.LocalPlayer
  2. local char = plr.Character
  3. local mouse = plr:GetMouse()
  4. local humanoid = char:findFirstChild("Humanoid")
  5. local torso = char:findFirstChild("Torso")
  6. local head = char.Head
  7. local ra = char:findFirstChild("Right Arm")
  8. local la = char:findFirstChild("Left Arm")
  9. local rl = char:findFirstChild("Right Leg")
  10. local ll = char:findFirstChild("Left Leg")
  11. local rs = torso:findFirstChild("Right Shoulder")
  12. local ls = torso:findFirstChild("Left Shoulder")
  13. local rh = torso:findFirstChild("Right Hip")
  14. local lh = torso:findFirstChild("Left Hip")
  15. local neck = torso:findFirstChild("Neck")
  16. local cam = workspace.CurrentCamera
  17.  
  18.  
  19.  
  20. OVERPowered = false
  21.  
  22. local spear = Instance.new("Model", char)
  23. spear.Name = "Spear"
  24.  
  25. local BG = Instance.new("BodyGyro")
  26. BG.maxTorque = Vector3.new(0, 20e+763, 0)
  27. BG.P = 20e+003
  28. BG.D = 100
  29.  
  30. local handle = Instance.new("Part", spear)
  31. handle.formFactor = "Custom"
  32. handle.Size = Vector3.new(0.2, 0.2, 4)
  33. handle.BrickColor = BrickColor.new("Brown")
  34. handle:BreakJoints()
  35. Instance.new("SpecialMesh", handle).MeshId = "http://www.roblox.com/asset/?id=43645078"
  36. handle.Mesh.Scale = Vector3.new(1.5, 1.5, 1.5)
  37.  
  38. local weld = Instance.new("Weld", handle)
  39. weld.C0 = CFrame.new(0, 0.95, 0) * CFrame.Angles(0, 0, 0)
  40. weld.Part0 = handle
  41. weld.Part1 = ra
  42.  
  43.  
  44. function animate()
  45. BGcframestored = mouse.Hit
  46. BG.Parent = torso
  47. coroutine.wrap(function()
  48. for i = 0, 70, 10 do
  49. neck.C0 = neck.C0 * CFrame.Angles(0, 0, math.rad(10))
  50. BG.cframe = BGcframestored * CFrame.Angles(0, -math.rad(i), 0)
  51. wait()
  52. end
  53. end)()
  54. rs.Parent = nil
  55. local ar = Instance.new("Part", spear)
  56. ar.FormFactor = "Custom"
  57. ar.Size = Vector3.new(1, 1, 1)
  58. ar.Transparency = 1
  59. ar.CanCollide = false
  60. ar.Locked = true
  61. ar:BreakJoints()
  62. local weld = Instance.new("Weld", ar)
  63. weld.C0 = CFrame.new(0, 0.5, 0)
  64. weld.Part0 = ra
  65. weld.Part1 = ar
  66. local motor = Instance.new("Motor", spear)
  67. motor.Part0 = torso
  68. motor.Part1 = ar
  69. motor.C0 = CFrame.new(1.5, 0.5, 0)
  70. for angle = 0, 180, 20 do
  71. motor.C0 = CFrame.new(1.5,0.5,0) * CFrame.Angles(math.rad(angle), -math.rad(60), 0)
  72. game:service'RunService'.Stepped:wait()
  73. end
  74.  
  75.  
  76.  
  77.  
  78. coroutine.wrap(function()
  79. for angle = 180, 0, -20 do
  80. motor.C0 = CFrame.new(1.5,0.5,0) * CFrame.Angles(math.rad(angle), -math.rad(angle/3), 0)
  81. game:service'RunService'.Stepped:wait()
  82. end
  83. end)()
  84. coroutine.wrap(function()
  85. wait(0.1)
  86. for i = 70, 0, -10 do
  87. neck.C0 = neck.C0 * CFrame.Angles(0, 0, -math.rad(10))
  88. BG.cframe = BGcframestored * CFrame.Angles(0, -math.rad(i), 0)
  89. wait()
  90. end
  91. wait(0.4)
  92. motor:Destroy()
  93. BG.Parent = nil
  94. rs.Parent = torso
  95. ar:Destroy()
  96. end)()
  97. end
  98.  
  99. --billboardGui func
  100.  
  101. function billboardGui(msg, objvar)
  102.  
  103. coroutine.wrap(function()
  104. local prt = Instance.new("Part", char)
  105. prt.FormFactor = "Custom"
  106. prt.Size = Vector3.new(0.1, 0.1, 0.1)
  107. prt.Transparency = 1
  108. prt.CanCollide = false
  109. prt.CFrame = CFrame.new(objvar.CFrame.x, objvar.CFrame.y, objvar.CFrame.z)
  110. prt.Anchored = true
  111.  
  112. local bg = Instance.new("BillboardGui")
  113. bg.Parent = prt
  114. bg.Adornee = prt
  115. bg.Size = UDim2.new(4, 0, 3.5, 0)
  116. bg.ExtentsOffset = Vector3.new(0, 0, 0)
  117. local lol = Instance.new("TextLabel")
  118. lol.Size = UDim2.new(1.3, 0, 0.4, 0)
  119. lol.TextScaled = true
  120. lol.TextWrapped = true
  121. lol.BackgroundTransparency = 1
  122. lol.Parent = bg
  123. lol.FontSize = "Size24"
  124. lol.TextColor3 = Color3.new(1, 0, 0)
  125. lol.TextStrokeTransparency = 0
  126. lol.Font = "ArialBold"
  127. lol.Text = (msg)
  128.  
  129. for _ = 2, 15, 1 do
  130. if prt == nil then return end
  131. prt.CFrame = prt.CFrame * CFrame.new(0, 0.2, 0)
  132. game:service'RunService'.Stepped:wait()
  133. end
  134. for _ = 0, 10 do
  135. lol.TextStrokeTransparency = lol.TextStrokeTransparency + 0.1
  136. lol.TextTransparency = lol.TextTransparency + 0.1
  137. wait()
  138. end
  139.  
  140. prt:Destroy()
  141. end)()
  142. end
  143.  
  144. --ray func
  145.  
  146. function rayCast(speed, gravity)
  147. coroutine.wrap(function()
  148.  
  149.  
  150.  
  151. local rayPart = Instance.new("Part")
  152.  
  153. rayPart.Name = "RayPart"
  154.  
  155. rayPart.BrickColor = BrickColor.new("Brown")
  156.  
  157. rayPart.Anchored = true
  158. rayPart.CanCollide = false
  159. rayPart.Locked = true
  160.  
  161. rayPart.TopSurface = Enum.SurfaceType.Smooth
  162. rayPart.BottomSurface = Enum.SurfaceType.Smooth
  163. rayPart.formFactor = Enum.FormFactor.Custom
  164. rayPart.Size = Vector3.new(0.2, 0.2, 3)
  165. Instance.new("SpecialMesh", rayPart).MeshId = "http://www.roblox.com/asset/?id=43645078"
  166. rayPart.Mesh.Scale = Vector3.new(1.5, 1.5, 1.5)
  167.  
  168.  
  169.  
  170.  
  171.  
  172. local bulletposition = handle.Position + Vector3.new(0, 0, 0)
  173.  
  174. local bulletvelocity = (Vector3.new(math.random(-2,2), math.random(-1,1), math.random(-2,2)))+( plr:GetMouse().Hit.p - bulletposition).unit*speed
  175. local bulletlastposition = bulletposition
  176.  
  177.  
  178.  
  179.  
  180.  
  181. coroutine.resume(coroutine.create(function()
  182. while true do
  183. local dt = wait()
  184. bulletlastposition = bulletposition
  185. bulletvelocity = bulletvelocity + (Vector3.new(0, -9.81*gravity, 0)*dt)
  186. bulletposition = bulletposition + (bulletvelocity*dt)
  187.  
  188. local ray = Ray.new(bulletlastposition, (bulletposition - bulletlastposition))
  189.  
  190. local hit, hitposition = workspace:FindPartOnRayWithIgnoreList( ray, { char, rayPart} )
  191.  
  192. if (torso.Position - rayPart.Position).magnitude > 540 then
  193. rayPart:Destroy()
  194. break
  195. end
  196.  
  197.  
  198. if hit then
  199. local damage = math.random(24, 32)
  200. if hit.Parent:findFirstChild("Humanoid") ~= nil then
  201. if OVERPowered then
  202. hit.Parent:BreakJoints()
  203. else
  204. hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - damage
  205. billboardGui("-"..damage, rayPart)
  206. end
  207.  
  208. end
  209.  
  210. if hit.Parent:IsA("Hat") and hit.Parent.Parent:findFirstChild("Humanoid") ~= nil then
  211. if OVERPowered then
  212. hit.Parent.Parent:BreakJoints()
  213. else
  214. hit.Parent.Parent.Humanoid.Health = hit.Parent.Parent.Humanoid.Health - damage
  215. billboardGui("-"..damage, rayPart)
  216. end
  217.  
  218.  
  219. if hit.Name == "Tire" and hit ~= nil then
  220. hit:BreakJoints()
  221. end
  222.  
  223. end
  224. bulletposition = hitposition
  225. if hit.Name == "RayPart" then
  226. hit:Destroy()
  227. rayPart:Destroy()
  228. else
  229. wait(5)
  230. rayPart:Destroy()
  231. end
  232. break
  233. end
  234. rayPart.CFrame = CFrame.new(bulletposition, bulletposition+bulletvelocity) * CFrame.Angles(-math.pi, 0, 0)
  235. rayPart.Parent = workspace
  236. end
  237. end))
  238. end)()
  239. end
  240.  
  241. mouse.Button1Down:connect(function(mouse)
  242. if char.Humanoid.Health == 0 then
  243. return end
  244. if debounce then return end
  245. debounce = true
  246. animate()
  247. rayCast(100, 7)
  248. wait(0.8)
  249. debounce = false
  250. end)
Add Comment
Please, Sign In to add comment