Submiter55

Weapon Template

Dec 18th, 2014
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.99 KB | None | 0 0
  1. Players = game:GetService("Players")
  2. Me = Players.BroFisty2
  3. Char = Me.Character
  4. necko = CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  5.  
  6. Selected = false
  7. Attacking = false
  8. Debounce = true
  9. Hurt = false
  10. ModelName = "Weapon"
  11. ToolName = "Weapon"
  12.  
  13. ContentProvider = game:GetService("ContentProvider")
  14.  
  15. V3 = Vector3.new
  16. C3 = Color3.new
  17. BN = BrickColor.new
  18. CN = CFrame.new
  19. CA = CFrame.Angles
  20. MR = math.rad
  21. MRA = math.random
  22. MP = math.pi
  23. MH = math.huge
  24. UD = UDim2.new
  25.  
  26. function RC(Pos, Dir, Max, Ignore)
  27. return workspace:FindPartOnRay(Ray.new(Pos, Dir.unit * (Max or 999)), Ignore)
  28. end
  29.  
  30. function RayC(Start, En, MaxDist, Ignore)
  31. return RC(Start, (En - Start), MaxDist, Ignore)
  32. end
  33.  
  34. function ComputePos(pos1, pos2)
  35. return CN(pos1, V3(pos2.x, pos1.y, pos2.z))
  36. end
  37.  
  38. function DetectSurface(pos, part)
  39. local surface = nil
  40. local pospos = part.CFrame
  41. local pos2 = pospos:pointToObjectSpace(pos)
  42. local siz = part.Size
  43. local shaep = part.Shape
  44. if shaep == Enum.PartType.Ball or shaep == Enum.PartType.Cylinder then
  45. surface = {"Anything", CN(pospos.p, pos)*CN(0, 0, -(pospos.p - pos).magnitude)*CA(MR(-90), 0, 0)}
  46. else
  47. if pos2.Y > ((siz.Y/2)-0.04) then
  48. surface = {"Top", CA(0, 0, 0)}
  49. elseif pos2.Y < -((siz.Y/2)-0.04) then
  50. surface = {"Bottom", CA(-MP, 0, 0)}
  51. elseif pos2.X > ((siz.X/2)-0.04) then
  52. surface = {"Right", CA(0, 0, MR(-90))}
  53. elseif pos2.X < -((siz.X/2)-0.04) then
  54. surface = {"Left", CA(0, 0, MR(90))}
  55. elseif pos2.Z > ((siz.Z/2)-0.04) then
  56. surface = {"Back", CA(MR(90), 0, 0)}
  57. elseif pos2.Z < -((siz.Z/2)-0.04) then
  58. surface = {"Front", CA(MR(-90), 0, 0)}
  59. end
  60. end
  61. return surface
  62. end
  63.  
  64. function Compute(pos1, pos2)
  65. local pos3 = Vector3.new(pos2.x, pos1.y, pos2.z)
  66. return CN(pos1, pos3)
  67. end
  68.  
  69. function waitChild(n, p)
  70. local c = p:findFirstChild(n)
  71. if c then return c end
  72. while true do
  73. c = p.ChildAdded:wait()
  74. if c.Name == n then return c end
  75. end
  76. end
  77.  
  78. function Notime(func)
  79. coroutine.resume(coroutine.create(function()
  80. func()
  81. end))
  82. end
  83.  
  84. Torso = waitChild("Torso", Char)
  85. Head = waitChild("Head", Char)
  86. Rarm = waitChild("Right Arm", Char)
  87. Larm = waitChild("Left Arm", Char)
  88. Rleg = waitChild("Right Leg", Char)
  89. Lleg = waitChild("Left Leg", Char)
  90. Neck = waitChild("Neck", Torso)
  91. Hum = waitChild("Humanoid", Char)
  92.  
  93. RSH = waitChild("Right Shoulder", Torso)
  94. LSH = waitChild("Left Shoulder", Torso)
  95. RH = waitChild("Right Hip", Torso)
  96. LH = waitChild("Left Hip", Torso)
  97.  
  98. RSH.Part0 = Torso
  99. LSH.Part0 = Torso
  100. RH.Part0 = Torso
  101. LH.Part0 = Torso
  102.  
  103. Add = {
  104. Mesh = function(P, ID, Scale, Tex)
  105. local m = Instance.new("SpecialMesh")
  106. m.MeshType = "FileMesh"
  107. m.MeshId = ID or ""
  108. m.Scale = Scale or V3(1, 1, 1)
  109. m.TextureId = Tex or ""
  110. m.Parent = P
  111. return m
  112. end,
  113. Sphere = function(P, Scale)
  114. local m = Instance.new("SpecialMesh")
  115. m.MeshType = "Sphere"
  116. m.Scale = Scale or V3(1, 1, 1)
  117. m.Parent = P
  118. return m
  119. end
  120. }
  121.  
  122. Sounds = {
  123. Shoot = {Id = "http://www.roblox.com/asset/?id=2697431", Pitch = 0.3, Volume = 0.5},
  124. Boom = {Id = "http://www.roblox.com/asset/?id=2692806", Pitch = 0.55, Volume = 0.4},
  125. Slash = {Id = "rbxasset://sounds//swordslash.wav", Pitch = 0.5, Volume = 0.5},
  126. Hit = {Id = "http://www.roblox.com/asset/?id=2801263", Pitch = 0.85, Volume = 0.35},
  127. Reload = {Id = "rbxasset://sounds\\metal.ogg", Pitch = 1, Volume = 0.45},
  128. }
  129.  
  130. for _,v in pairs(Sounds) do
  131. ContentProvider:Preload(v.Id)
  132. end
  133.  
  134. function PlaySound(Sound, bool)
  135. local s = Instance.new("Sound")
  136. s.Looped = false
  137. s.Volume = Sound.Volume
  138. s.SoundId = Sound.Id
  139. if bool then
  140. s.Pitch = MRA((Sound.Pitch*0.75)*1000, (Sound.Pitch*1.15)*1000)/1000
  141. else
  142. s.Pitch = Sound.Pitch
  143. end
  144. s.PlayOnRemove = true
  145. s.Parent = Torso
  146. Notime(function()
  147. wait()
  148. s.Parent = nil
  149. end)
  150. end
  151.  
  152. function GetParts(pos, dist)
  153. local parts = {}
  154. local function o(p)
  155. for _,v in pairs(p:children()) do
  156. if v:IsA("BasePart") then
  157. if (pos - v.Position).magnitude <= dist then
  158. table.insert(parts, {v, (pos - v.Position).magnitude, v.Anchored})
  159. end
  160. end
  161. o(v)
  162. end
  163. end
  164. o(workspace)
  165. return parts
  166. end
  167.  
  168. function GetHum(P)
  169. for _,v in pairs(P:children()) do
  170. if v:IsA("Humanoid") then
  171. if v.Health > 0 then
  172. return v
  173. end
  174. end
  175. end
  176. end
  177.  
  178. function GetGroup(Pos, Distance, Hit)
  179. local tab = {}
  180. for _,v in pairs(workspace:children()) do
  181. local h = GetHum(v)
  182. local t = v:findFirstChild("Torso")
  183. if h and t and v ~= Hit.Parent then
  184. if (t.Position - Pos).magnitude <= Distance then
  185. table.insert(tab, {h, v, (t.Position - Pos).magnitude})
  186. end
  187. end
  188. end
  189. if Hit then
  190. local h = GetHum(Hit.Parent)
  191. if h then
  192. table.insert(tab, {h, Hit.Parent, 0})
  193. end
  194. end
  195. return tab
  196. end
  197.  
  198. function Part(Par, Anc, Colli, Tran, Ref, Col, Siz)
  199. local p = Instance.new("Part")
  200. p.formFactor = "Custom"
  201. p.TopSurface = 0
  202. p.BottomSurface = 0
  203. p.Transparency = Tran
  204. p.Reflectance = Ref
  205. p.Anchored = Anc
  206. p.CanCollide = Colli
  207. p.BrickColor = Col
  208. p.Size = Siz
  209. p.Locked = true
  210. p.Parent = Par
  211. p:BreakJoints()
  212. return p
  213. end
  214.  
  215. function Weld(P0, P1, C0, C1)
  216. local w = Instance.new("Weld")
  217. w.Part0 = P0
  218. w.Part1 = P1
  219. if C0 then
  220. w.C0 = C0
  221. end
  222. if C1 then
  223. w.C1 = C1
  224. end
  225. w.Parent = P0
  226. return w
  227. end
  228.  
  229. for _,v in pairs(Char:children()) do
  230. if v.Name == ModelName then
  231. v:remove()
  232. end
  233. end
  234.  
  235. Model = Instance.new("Model")
  236. Model.Name = ModelName
  237.  
  238. FTorso = Part(Model, false, false, 1, 0, Torso.BrickColor, V3(2, 2, 1))
  239. FW = Weld(Torso, FTorso)
  240.  
  241. RAB = Part(Model, false, false, 1, 0, BN("White"), V3(0.2, 0.2, 0.2))
  242. LAB = Part(Model, false, false, 1, 0, BN("White"), V3(0.2, 0.2, 0.2))
  243. RLB = Part(Model, false, false, 1, 0, BN("White"), V3(0.2, 0.2, 0.2))
  244. LLB = Part(Model, false, false, 1, 0, BN("White"), V3(0.2, 0.2, 0.2))
  245.  
  246. RABW = Weld(Torso, RAB, CN(), CN(-1.5, -0.5, 0))
  247. LABW = Weld(Torso, LAB, CN(), CN(1.5, -0.5, 0))
  248. RLBW = Weld(Torso, RLB, CN(), CN(-0.5, 1, 0))
  249. LLBW = Weld(Torso, LLB, CN(), CN(0.5, 1, 0))
  250.  
  251. RAW = Weld(RAB, nil, CN(), CN(0, 0.5, 0))
  252. LAW = Weld(LAB, nil, CN(), CN(0, 0.5, 0))
  253. RLW = Weld(RLB, nil, CN(), CN(0, 1, 0))
  254. LLW = Weld(LLB, nil, CN(), CN(0, 1, 0))
  255.  
  256. TW = Weld(Torso, nil, CN(0.7, 0.8, 1.2), CA(0, MR(180), MR(55)))
  257.  
  258. Weapon = Instance.new("Model")
  259. Weapon.Name = "Weapon"
  260.  
  261. HB = Part(Weapon, false, false, 1, 0, BN("White"), V3(0.2, 0.2, 0.2))
  262. HBW = Weld(Rarm, HB, CN(0, -0.7, 0), CA(0, MR(90), MR(90)))
  263. HW = Weld(HB, nil)
  264.  
  265. function Show_Damage(P, D)
  266. local mo = Instance.new("Model")
  267. mo.Name = D
  268. local p = Part(mo, false, false, 0, 0, BN("Bright red"), V3(0.2, 0.2, 0.2))
  269. p.Name = "Head"
  270. local m = Instance.new("SpecialMesh")
  271. m.MeshType = "Brick"
  272. m.Scale = Vector3.new(4.5, 2.3, 4.5)
  273. m.Parent = p
  274. local bp = Instance.new("BodyPosition", p)
  275. bp.maxForce = V3(MH, MH, MH)
  276. bp.P = 9001
  277. bp.position = CN(P) * CN(0, 1.5, 0).p
  278. local h = Instance.new("Humanoid")
  279. h.Health = 0
  280. h.MaxHealth = 0
  281. h.Name = "asd"
  282. h.Parent = mo
  283. local nah = true
  284. mo.Parent = workspace
  285. p.CFrame = CN(P)
  286. Notime(function()
  287. wait(1.5)
  288. for i = 0, 1, 0.05 do
  289. p.Transparency = i
  290. if nah then mo.Name = "" nah = false else mo.Name = "- "..D nah = true end
  291. wait()
  292. end
  293. mo:remove()
  294. end)
  295. end
  296.  
  297. Weapon.Parent = Model
  298. Model.Parent = Char
  299.  
  300. if script.Parent.className ~= "HopperBin" then
  301. h = Instance.new("HopperBin", Me.Backpack)
  302. h.Name = ToolName
  303. script.Parent = h
  304. end
  305.  
  306. bin = script.Parent
  307.  
  308. function Attach(t)
  309. RSH.Part0 = t
  310. LSH.Part0 = t
  311. RH.Part0 = t
  312. LH.Part0 = t
  313. RABW.Part0 = t
  314. LABW.Part0 = t
  315. LLBW.Part0 = t
  316. RLBW.Part0 = t
  317. if t == Torso then
  318. FTorso.Transparency = 1
  319. else
  320. Torso.Transparency = 1
  321. end
  322. t.Transparency = 0
  323. end
  324.  
  325. function SelectAnim()
  326. end
  327.  
  328. function DeselAnim()
  329. end
  330.  
  331. function onSelected(mouse)
  332. SelectAnim()
  333. Selected = true
  334. mouse.Button1Down:connect(function()
  335. end)
  336. mouse.KeyDown:connect(function(key)
  337. key = key:lower()
  338. end)
  339. end
  340.  
  341. function onDeselected(mouse)
  342. Selected = false
  343. DeselAnim()
  344. end
  345.  
  346. bin.Selected:connect(onSelected)
  347. bin.Deselected:connect(onDeselected)
Advertisement
Add Comment
Please, Sign In to add comment