codemen

Antis Bow script [roblox]

Nov 22nd, 2017
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.37 KB | None | 0 0
  1. function weld(p0,p1,c0,c1,par)
  2. local w = Instance.new("Weld",p0 or par)
  3. w.Part0 = p0
  4. w.Part1 = p1
  5. w.C0 = c0 or CFrame.new()
  6. w.C1 = c1 or CFrame.new()
  7. return w
  8. end
  9. do -- Credit to Stravant...
  10. local function QuaternionFromCFrame(cf) local mx, my, mz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = cf:components() local trace = m00 + m11 + m22 if trace > 0 then local s = math.sqrt(1 + trace) local recip = 0.5/s return (m21-m12)*recip, (m02-m20)*recip, (m10-m01)*recip, s*0.5 else local i = 0 if m11 > m00 then i = 1 end if m22 > (i == 0 and m00 or m11) then i = 2 end if i == 0 then local s = math.sqrt(m00-m11-m22+1) local recip = 0.5/s return 0.5*s, (m10+m01)*recip, (m20+m02)*recip, (m21-m12)*recip elseif i == 1 then local s = math.sqrt(m11-m22-m00+1) local recip = 0.5/s return (m01+m10)*recip, 0.5*s, (m21+m12)*recip, (m02-m20)*recip elseif i == 2 then local s = math.sqrt(m22-m00-m11+1) local recip = 0.5/s return (m02+m20)*recip, (m12+m21)*recip, 0.5*s, (m10-m01)*recip end end end
  11.  
  12. local function QuaternionToCFrame(px, py, pz, x, y, z, w) local xs, ys, zs = x + x, y + y, z + z local wx, wy, wz = w*xs, w*ys, w*zs local xx = x*xs local xy = x*ys local xz = x*zs local yy = y*ys local yz = y*zs local zz = z*zs return CFrame.new(px, py, pz,1-(yy+zz), xy - wz, xz + wy,xy + wz, 1-(xx+zz), yz - wx, xz - wy, yz + wx, 1-(xx+yy)) end
  13.  
  14. local function QuaternionSlerp(a, b, t) local cosTheta = a[1]*b[1] + a[2]*b[2] + a[3]*b[3] + a[4]*b[4] local startInterp, finishInterp; if cosTheta >= 0.0001 then if (1 - cosTheta) > 0.0001 then local theta = math.acos(cosTheta) local invSinTheta = 1/math.sin(theta) startInterp = math.sin((1-t)*theta)*invSinTheta finishInterp = math.sin(t*theta)*invSinTheta else startInterp = 1-t finishInterp = t end else if (1+cosTheta) > 0.0001 then local theta = math.acos(-cosTheta) local invSinTheta = 1/math.sin(theta) startInterp = math.sin((t-1)*theta)*invSinTheta finishInterp = math.sin(t*theta)*invSinTheta else startInterp = t-1 finishInterp = t end end return a[1]*startInterp + b[1]*finishInterp, a[2]*startInterp + b[2]*finishInterp, a[3]*startInterp + b[3]*finishInterp, a[4]*startInterp + b[4]*finishInterp end
  15. function clerp(a,b,t)
  16. if not a or not b then print(a,b,"is missing") return end
  17. local qa = {QuaternionFromCFrame(a)}
  18. local qb = {QuaternionFromCFrame(b)}
  19. local ax, ay, az = a.x, a.y, a.z
  20. local bx, by, bz = b.x, b.y, b.z
  21. local _t = 1-t
  22. return QuaternionToCFrame(_t*ax + t*bx, _t*ay + t*by, _t*az + t*bz,QuaternionSlerp(qa, qb, t))
  23. end
  24. end
  25. local oc = oc or function(...) return ... end
  26. pcall(function() script.Parent.bScript:Destroy() end)
  27. script.Name = "bScript"
  28. local plr = game:service'Players'.LocalPlayer
  29. local mouse = plr:GetMouse()
  30. local char = plr.Character
  31. local tor,ra,la,rl,ll,hd,hum = char.Torso,char["Right Arm"],char["Left Arm"],char["Right Leg"],char["Left Leg"],char.Head,char.Humanoid
  32. local rrs,rls,nk = tor["Right Shoulder"],tor["Left Shoulder"],tor.Neck
  33. local nk0 = nk.C0
  34. local rc0,rc1 = rrs.C0,rrs.C1
  35. local lc0,lc1 = rls.C0,rls.C0
  36. local rs,ls = rrs:Clone(),rls:Clone()
  37. rs.Name,ls.Name = "rs","ls"
  38. rs.DesiredAngle,rs.CurrentAngle = 0,0
  39. ls.DesiredAngle,ls.CurrentAngle = 0,0
  40. local model = Instance.new("Model",char)
  41. pcall(function() char.bModel:Destroy() end)
  42. model.Name = "bModel"
  43. local part = Instance.new("Part")
  44. part.BrickColor = BrickColor.new("Really black")
  45. part.Reflectance = 0.15
  46. part.FormFactor = "Custom"
  47. part.TopSurface,part.BottomSurface = 0,0
  48. part.Size = Vector3.new(.2,.2,.2)
  49. part:BreakJoints()
  50. part.CanCollide = false
  51. function clone(t)
  52. local p = t:Clone()
  53. p.Parent = t.Parent or model
  54. return p
  55. end
  56. local han = clone(part)
  57. han.Size = Vector3.new(.3,.5,.3)
  58. han.Transparency = 1
  59. local hold = weld(la,han,CFrame.new(0,-1,0) * CFrame.Angles(math.rad(-90),math.rad(23),0),CFrame.new())
  60. for i=1,14 do
  61. local gr = clone(part)
  62. gr.BrickColor = BrickColor.new("Silver")
  63. gr.Size = Vector3.new(.3,.2,.3)
  64. local m = Instance.new("SpecialMesh",gr)
  65. m.MeshType = "Sphere"
  66. m.Scale = Vector3.new(1,.75,1) * math.max(.85,math.abs(i-7)/5)
  67. weld(han,gr,CFrame.new(0,-.6+i*.085,0) * CFrame.Angles(math.rad(15),math.rad(0),math.rad(23)),CFrame.new())
  68. end
  69. local p = clone(part)
  70. p.Size = Vector3.new(.45,.2,.32)
  71. local m = Instance.new("BlockMesh",p)
  72. m.Scale = Vector3.new(1,.5,1)
  73. weld(han,p,CFrame.new(0,-.62,.125) * CFrame.Angles(math.rad(10),0,0))
  74. local p = clone(part)
  75. p.Size = Vector3.new(.45,.2,.3)
  76. local m = Instance.new("BlockMesh",p)
  77. m.Scale = Vector3.new(1,.5,1)
  78. weld(han,p,CFrame.new(0,-.62,-.125) * CFrame.Angles(math.rad(-10),0,0))
  79. local b1 = clone(part)
  80. b1.Size = Vector3.new(.2,1,.3)
  81. local m = Instance.new("BlockMesh",b1)
  82. m.Scale = Vector3.new(1,1,1)
  83. local bw1 = weld(han,b1,CFrame.new(0,-.6,0) * CFrame.Angles(math.rad(-10),0,0),CFrame.new(0,.5,0))
  84. local b2 = clone(part)
  85. b2.Size = Vector3.new(.2,1,.25)
  86. local m = Instance.new("BlockMesh",b2)
  87. m.Scale = Vector3.new(.9,1,1)
  88. local bw2 = weld(b1,b2,CFrame.new(0,-.5,-.15) * CFrame.Angles(math.rad(-25),0,0),CFrame.new(0,.5,-.125))
  89. local b3 = clone(part)
  90. b3.Size = Vector3.new(.2,1,.2)
  91. local m = Instance.new("BlockMesh",b3)
  92. m.Scale = Vector3.new(.75,1,1)
  93. local bw3 = weld(b2,b3,CFrame.new(0,-.5,-.125) * CFrame.Angles(math.rad(-25),0,0),CFrame.new(0,.5,-.1))
  94. local bt = clone(part)
  95. bt.BrickColor = BrickColor.new("Black")
  96. bt.Size = Vector3.new(.2,.3,.2)
  97. local m = Instance.new("BlockMesh",bt)
  98. m.Scale = Vector3.new(.5,1,1) * .5
  99. local btw = weld(b3,bt,CFrame.new(0,-.5,.1) * CFrame.Angles(math.rad(-25),0,0),CFrame.new(0,0,.05))
  100. local p = clone(part)
  101. p.Size = Vector3.new(.45,.2,.32)
  102. local m = Instance.new("BlockMesh",p)
  103. m.Scale = Vector3.new(1,.5,1)
  104. weld(han,p,CFrame.new(0,.67,.125) * CFrame.Angles(math.rad(15),0,0))
  105. local p = clone(part)
  106. p.Size = Vector3.new(.45,.2,.3)
  107. local m = Instance.new("BlockMesh",p)
  108. m.Scale = Vector3.new(1,.5,1)
  109. weld(han,p,CFrame.new(0,.67,-.125) * CFrame.Angles(math.rad(-15),0,0))
  110. local p = clone(part)
  111. p.Size = Vector3.new(.4,.2,.3)
  112. local m = Instance.new("BlockMesh",p)
  113. m.Scale = Vector3.new(1,.5,1)
  114. weld(han,p,CFrame.new(0,.75,0) * CFrame.Angles(math.rad(0),0,0))
  115. local p = clone(part)
  116. p.Size = Vector3.new(.2,.3,.35)
  117. local m = Instance.new("BlockMesh",p)
  118. m.Scale = Vector3.new(1,1,1)
  119. weld(han,p,CFrame.new(-.1,.8,0) * CFrame.Angles(math.rad(0),0,0))
  120. local p = clone(part)
  121. p.Size = Vector3.new(.45,.2,.32)
  122. local m = Instance.new("BlockMesh",p)
  123. m.Scale = Vector3.new(1,.5,1)
  124. weld(han,p,CFrame.new(0,1,.125) * CFrame.Angles(math.rad(-5),0,0))
  125. local p = clone(part)
  126. p.Size = Vector3.new(.45,.2,.25)
  127. local m = Instance.new("BlockMesh",p)
  128. m.Scale = Vector3.new(1,.5,1)
  129. weld(han,p,CFrame.new(0,1,-.125) * CFrame.Angles(math.rad(5),0,0))
  130. local t1 = clone(part)
  131. t1.Size = Vector3.new(.2,1,.3)
  132. local m = Instance.new("BlockMesh",t1)
  133. m.Scale = Vector3.new(1,1,1)
  134. local tw1 = weld(han,t1,CFrame.new(0,.975,0) * CFrame.Angles(math.rad(10),0,0),CFrame.new(0,-.5,0))
  135. local t2 = clone(part)
  136. t2.Size = Vector3.new(.2,1,.25)
  137. local m = Instance.new("BlockMesh",t2)
  138. m.Scale = Vector3.new(.9,1,1)
  139. local tw2 = weld(t1,t2,CFrame.new(0,.5,-.15) * CFrame.Angles(math.rad(25),0,0),CFrame.new(0,-.5,-.125))
  140. local t3 = clone(part)
  141. t3.Size = Vector3.new(.2,1,.2)
  142. local m = Instance.new("BlockMesh",t3)
  143. m.Scale = Vector3.new(.75,1,1)
  144. local tw3 = weld(t2,t3,CFrame.new(0,.5,-.125) * CFrame.Angles(math.rad(25),0,0),CFrame.new(0,-.5,-.1))
  145. local tt = clone(part)
  146. tt.BrickColor = BrickColor.new("Black")
  147. tt.Size = Vector3.new(.2,.3,.2)
  148. local m = Instance.new("BlockMesh",tt)
  149. m.Scale = Vector3.new(.5,1,1) * .5
  150. local ttw = weld(t3,tt,CFrame.new(0,.5,.1) * CFrame.Angles(math.rad(25),0,0),CFrame.new(0,0,.05))
  151. local W = {bw1,bw2,bw3,tw1,tw2,tw3}
  152. local W0 = {bw1.C0,bw2.C0,bw3.C0,tw1.C0,tw2.C0,tw3.C0}
  153. local l1 = clone(part)
  154. l1.BrickColor = BrickColor.new("Light reddish violet")
  155. l1.Size = Vector3.new(.2,.2,.2)
  156. local m = Instance.new("CylinderMesh",l1)
  157. local l1w = weld(bt,l1)
  158. local l2 = clone(l1)
  159. local l2w = weld(tt,l2)
  160. local amodel = Instance.new("Model")
  161. local arrow = clone(part)
  162. arrow.Parent = amodel
  163. arrow.BrickColor = BrickColor.new("Brown")
  164. arrow.Size = Vector3.new(.2,3,.2)
  165. arrow.Name = "main"
  166. local m = Instance.new("CylinderMesh",arrow)
  167. m.Scale = Vector3.new(.5,1,.5)
  168. local arrw = weld(han,arrow)
  169. local tip = clone(part)
  170. tip.Parent = amodel
  171. tip.BrickColor = BrickColor.new("Cool yellow")
  172. tip.Size = Vector3.new(.2,.4,.2)
  173. tip.Name = "tip"
  174. local m = Instance.new("SpecialMesh",tip)
  175. m.MeshId = "rbxassetid://1033714"
  176. m.Scale = Vector3.new(.1,.45,.1)
  177. weld(arrow,tip,CFrame.new(0,1.6,0))
  178. local walkspeed = 16
  179. local hpos_i = CFrame.new(0,.8,1.3)
  180. local hpos_l = CFrame.new(0,.8,1.55)
  181. local hpos = hpos_i
  182. local keeper = Vector3.new(0.07,0.82,0)
  183. mouse.Button1Up:connect(function()
  184. mup = true
  185. end)
  186. function ragJoint(hit,r,d)
  187. Spawn(oc(function()
  188. d = d or 0
  189. local rpar,r0,r1 = r.Parent,r.Part0,r.Part1
  190. if d > 0 then wait(d) end
  191. local p = hit:Clone()
  192. p:BreakJoints()
  193. p:ClearAllChildren()
  194. p.FormFactor = "Custom"
  195. p.Size = p.Size/2
  196. p.Transparency = 1
  197. p.CanCollide = true
  198. p.Name = "Colliduh"
  199. p.Parent = hit
  200. local w = Instance.new("Weld",p)
  201. w.Part0 = hit
  202. w.Part1 = p
  203. w.C0 = CFrame.new(0,-p.Size.Y/2,0)
  204. local rot = Instance.new("Rotate",rpar)
  205. rot.Name = r.Name
  206. rot.Part0 = r0
  207. rot.Part1 = r1
  208. rot.C0 = r.C0
  209. rot.C1 = r.C1
  210. r0.Velocity = Vector3.new()
  211. r1.Velocity = Vector3.new()
  212. r:Destroy()
  213. end))
  214. end
  215. function ShootArrow(a,to,spd)
  216. Spawn(oc(function()
  217. local from = a.main.CFrame
  218. a:Destroy()
  219. local a = amodel:Clone()
  220. for i,v in pairs(a:GetChildren()) do
  221. if v:IsA("BasePart") then
  222. v.Anchored = true
  223. end
  224. end
  225. a:MakeJoints()
  226. a.Parent = workspace
  227. local m = a.main
  228. --local from = m.CFrame
  229. local t = {}
  230. local function move(cf)
  231. for i,v in pairs(a:GetChildren()) do
  232. if v ~= m and v:IsA("BasePart") then
  233. t[v] = t[v] or m.CFrame:toObjectSpace(v.CFrame)
  234. v.CFrame = cf * t[v]
  235. end
  236. end
  237. m.CFrame = cf
  238. end
  239. move(from)
  240. local velocity = (to.p-from.p).unit * spd * 500
  241. local con
  242. local t = tick()
  243. con = game:GetService("RunService").Stepped:connect(function()
  244. if tick()-t > 25 then
  245. con:disconnect()
  246. a:Destroy()
  247. return
  248. end
  249. velocity = velocity - Vector3.new(0,196.2/30,0)
  250. local newcf = clerp(m.CFrame,CFrame.new(m.Position,m.Position+velocity) * CFrame.Angles(-math.pi/2,0,0),.5) + velocity / 30
  251. local hit,ray
  252. local rayo = Ray.new(m.Position,newcf.p-m.Position)
  253. local ign = {a,char}
  254. repeat
  255. hit,ray = workspace:FindPartOnRayWithIgnoreList(rayo,ign)
  256. if not hit then break end
  257. if hit.CanCollide or game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) then
  258. break
  259. else
  260. table.insert(ign,hit)
  261. hit = nil
  262. end
  263. until false
  264. if hit then
  265. move(newcf-newcf.p+ray)
  266. con:disconnect()
  267. game:GetService("Debris"):AddItem(a,300)
  268. local char = hit.Parent
  269. if not hit.Anchored then
  270. local b = hit.CFrame:toObjectSpace(m.CFrame)
  271. for i,v in pairs(a:GetChildren()) do
  272. pcall(function() v.Anchored = false v.CanCollide = true end)
  273. end
  274. weld(hit,m,b)
  275. end
  276. if game:service'Players':GetPlayerFromCharacter(char) and char:FindFirstChild("Torso") then
  277. if hit.Name:match("Arm") then
  278. local r = char.Torso:FindFirstChild(hit.Name:gsub("Arm","Shoulder"):gsub("Leg","Hip"))
  279. if r then
  280. ragJoint(hit,r)
  281. end
  282. elseif hit.Name:match("Head") then
  283. for i,v in pairs(char:GetChildren()) do
  284. local r = char.Torso:FindFirstChild(v.Name:gsub("Arm","Shoulder"):gsub("Leg","Hip"))
  285. if v:IsA("BasePart") and r then
  286. ragJoint(v,r,.1)
  287. elseif v:IsA("Humanoid") then
  288. v.PlatformStand = true
  289. v.Changed:connect(function()
  290. v.PlatformStand = true
  291. end)
  292. end
  293. end
  294. Delay(8,function()
  295. char:BreakJoints()
  296. end)
  297. end
  298. end
  299. return
  300. else
  301. move(newcf)
  302. end
  303. end)
  304. end))
  305. end
  306. mouse.Button1Down:connect(oc(function()
  307. if mb then return end
  308. mb = true
  309. mup = false
  310. rls.Part0,rls.Part1 = nil,nil
  311. ls.Part0,ls.Part1 = tor,la
  312. ls.Parent = tor
  313. ls.C0 = ls.C0 * CFrame.Angles(0,0,rls.CurrentAngle)
  314. rrs.Part0,rrs.Part1 = nil,nil
  315. rs.Part0,rs.Part1 = tor,ra
  316. rs.Parent = tor
  317. rs.C0 = rs.C0 * CFrame.Angles(0,0,rrs.CurrentAngle)
  318. local hc0 = hold.C0
  319. local bg = Instance.new("BodyGyro",tor)
  320. bg.maxTorque = Vector3.new(1,1,1)*9e7
  321. local ltar = 0
  322. local rtar = rrs.C0 * CFrame.Angles(0,0,math.rad(90)) * CFrame.Angles(math.rad(70),0,0) + Vector3.new(-.65,.25,-.25)
  323. local ntar = nk0 * CFrame.Angles(0,0,math.rad(70))
  324. local htar = hc0 * CFrame.Angles(0,math.rad(10),0)
  325. local t = tick()
  326. local iam = 0
  327. local ham = .3
  328. local lend = false
  329. local ended
  330. local arr = amodel:Clone()
  331. arr.Parent = model
  332. arr:MakeJoints()
  333. hum.WalkSpeed = walkspeed/1.5
  334. local aw = weld(ra,arr.main,CFrame.new(0,-1,0)*CFrame.Angles(-math.pi/2,0,0),CFrame.new(0,-1.5,0))
  335. func = function()
  336. local a = (mouse.Hit.p-tor.CFrame:toWorldSpace(ls.C0).p).unit
  337. bg.cframe = CFrame.new(tor.Position,mouse.Hit.p*Vector3.new(1,0,1)+tor.Position*Vector3.new(0,1,0)) * CFrame.Angles(0,math.rad(-75),0)
  338. local b = math.min(.7,math.max(-.7,a.Y))
  339. ls.C0 = clerp(ls.C0,rls.C0 * CFrame.Angles(math.rad(-90),math.rad(90),math.rad(b*-90)) * CFrame.Angles(math.rad(40),math.rad(0),0) + Vector3.new(math.abs(b)*0,-.25,-.6),.3)
  340. local c = tor.CFrame:toObjectSpace(han.CFrame*hpos) * CFrame.new(0,0,0)
  341. local d = Vector3.new(1,.6,0)
  342. rs.C1 = CFrame.new()
  343. rs.C0 = clerp(rs.C0,CFrame.new(d,c.p) * CFrame.new(0,0,-(c.p-d).magnitude+.95) * CFrame.Angles(math.pi/2,math.pi/2,0),.3)
  344. nk.C0 = clerp(nk.C0,ntar * CFrame.Angles(math.rad(math.floor(b*-90)),0,0),.3)
  345. hold.C0 = clerp(hold.C0,htar,.3)
  346. for i,v in pairs(W) do
  347. -- v.C0 = clerp(v.C0,W0[i] * CFrame.Angles((not mup and (i>3 and 1 or -1)*iam or 0)*.1,0,0),.6)
  348. v.C0 = clerp(v.C0,W0[i] * CFrame.Angles((not mup and (i>3 and 1 or -1)*iam or 0)*.1,0,0),.6)
  349. end
  350. if not mup then
  351. hpos = clerp(hpos,hpos_l * CFrame.new(0,0,iam),.2)
  352. if aw then aw.C0 = CFrame.new(Vector3.new(0,-1,0),ra.CFrame:toObjectSpace(han.CFrame*CFrame.new(keeper)).p) * CFrame.Angles(-math.pi/2,0,0) end
  353. if tick()-t > .5 and iam < 1 then
  354. iam = iam + math.max(0.003,.03-(tick()-t-.5)/70)
  355. ham = iam
  356. if aw then
  357. aw:Destroy()
  358. arrw.Parent = han
  359. arrw.Part0 = han
  360. arrw.Part1 = arr.main
  361. aw = nil
  362. end
  363. end
  364. else
  365. hpos = clerp(hpos,hpos_l,ham/math.max(0.01,(hpos.p-hpos_l.p).magnitude))
  366. ham = ham * .7
  367. if not ended then
  368. ended = true
  369. if iam > 0 then
  370. arrw.Part1 = nil
  371. ShootArrow(arr,mouse.Hit,iam)
  372. iam = iam + .2
  373. wait(.5)
  374. lend = true
  375. else
  376. wait(.1)
  377. arr:Destroy()
  378. lend = true
  379. end
  380. end
  381. end
  382. end
  383. repeat wait() until lend or tick()-t > 45
  384. mup = nil
  385. func = nil
  386. hum.WalkSpeed = walkspeed
  387. ls.Part0,ls.Part1 = nil,nil
  388. ls.Parent = nil
  389. rls.Part0,rls.Part1 = tor,la
  390. ls.C0 = rls.C0
  391. rs.Part0,rs.Part1 = nil,nil
  392. rs.Parent = nil
  393. rrs.Part0,rrs.Part1 = tor,ra
  394. rs.C0 = rrs.C0
  395. nk.C0 = nk0
  396. bg:Destroy()
  397. hold.C0 = hc0
  398. hpos = hpos_i
  399. mb = false
  400. end))
  401. rcon = game:GetService("RunService").Stepped:connect(oc(function()
  402. if not model:IsDescendantOf(workspace) then rcon:disconnect() error() return end
  403. --local tc = bt.CFrame:toObjectSpace(tt.CFrame)
  404. --local bc = tt.CFrame:toObjectSpace(bt.CFrame)
  405. local bm = bt.CFrame:toObjectSpace(han.CFrame*hpos)
  406. local tm = tt.CFrame:toObjectSpace(han.CFrame*hpos)
  407. l1w.C0 = CFrame.new(bm.p/2,bm.p) * CFrame.Angles(math.pi/2,0,0)
  408. l1.Mesh.Scale = Vector3.new(.2,bm.p.magnitude*5,.2)
  409. l2w.C0 = CFrame.new(tm.p/2,tm.p) * CFrame.Angles(math.pi/2,0,0)
  410. l2.Mesh.Scale = Vector3.new(.2,tm.p.magnitude*5,.2)
  411. arrw.C0 = CFrame.new(hpos.p,keeper)*CFrame.new(0,0,-arrow.Size.Y/2) * CFrame.Angles(-math.pi/2,0,0)
  412. if func then
  413. func()
  414. end
  415. end))
Add Comment
Please, Sign In to add comment