Advertisement
Theskyler900

Untitled

Aug 31st, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 65.86 KB | None | 0 0
  1. local tool=Instance.new("HopperBin", game.Players.LocalPlayer.Backpack)
  2. tool.Name="Knife"
  3.  
  4. wait()
  5. script.Parent=tool
  6.  
  7. --Murderer knife action script, original code from The Mad Murderer, by loleris.
  8.  
  9. wait()
  10. local camera = game.Workspace.CurrentCamera
  11. local player = game.Players.LocalPlayer
  12. local character = player.Character
  13. local humanoid = character.Humanoid
  14. local head = character.Head
  15. local torso = character.Torso
  16. local pl_mouse = player:GetMouse()
  17.  
  18. local rs = game:GetService("RunService")
  19.  
  20. local stab_damage = 110
  21. local walkspeeds = {16, 19}
  22.  
  23. Settings = {
  24. Equip_time = 0.4,
  25. Idle_speed = 5,
  26. Attack_speed = 0.65,
  27. }
  28.  
  29. local assetlink = "http://www.roblox.com/asset/?id="
  30. local hit_sounds = {"153647516", "153647519", "153647522", "153647526"}
  31. local death_sounds = {"146594640", "146594648", "146457047"}
  32. function Clean(obj)
  33. spawn(function()
  34. wait(6)
  35. obj:remove()
  36. end)
  37. end
  38.  
  39. function HIT_HANDLE(hit, dmg, pos)
  40. if hit == nil then return end
  41. local h = hit.Parent:findFirstChild("Humanoid")
  42. if h == nil then
  43. h = hit.Parent.Parent:findFirstChild("Humanoid")
  44. end
  45. if h == nil then return end
  46. if h.Health <= 0 then return end
  47.  
  48. local head = h.Parent:findFirstChild("Head")
  49. if head == nil then return end
  50.  
  51. local sound_part = Instance.new("Part")
  52. sound_part.formFactor = "Custom"
  53. sound_part.Size = Vector3.new(0.2, 0.2, 0.2)
  54. sound_part.Transparency = 1
  55. sound_part.CanCollide = false
  56. sound_part.Anchored = true
  57. sound_part.CFrame = head.CFrame
  58. Clean(sound_part)
  59. sound_part.Parent = Workspace
  60. local s_hit = Instance.new("Sound")
  61. s_hit.Volume = 1
  62. s_hit.SoundId = assetlink .. hit_sounds[math.random(1, #hit_sounds)]
  63. s_hit.Parent = sound_part
  64. local s_die = Instance.new("Sound")
  65. s_die.Volume = 1
  66. s_die.SoundId = assetlink .. death_sounds[math.random(1, #death_sounds)]
  67. s_die.Parent = sound_part
  68.  
  69. s_hit:play()
  70.  
  71. local c_tag = Instance.new("ObjectValue")
  72. c_tag.Name = "creator"
  73. c_tag.Value = player
  74. c_tag.Parent = h
  75. h.Health=0
  76. s_die:play()
  77. end
  78.  
  79. function GENERATE_IGNORELIST()
  80. local result = {character, camera}
  81. local plr = game.Players:GetPlayers()
  82. for i = 1, #plr do
  83. if plr[i] ~= player then
  84. local char = plr[i].Character
  85. if char ~= nil then
  86. local ch = char:GetChildren()
  87. for i = 1, #ch do
  88. if ch[i]:IsA("Hat") or ch[i]:IsA("Tool") then
  89. result[#result + 1] = ch[i]
  90. end
  91. end
  92. end
  93. end
  94. end
  95. return result
  96. end
  97.  
  98. function RayCast(pos1, pos2, dist, ign)
  99. local ray = Ray.new(
  100. pos1,
  101. (pos2 - pos1).unit * math.abs(dist)
  102. )
  103. local hit, hpos = Workspace:FindPartOnRayWithIgnoreList(ray, ign, false)
  104. return hit, hpos
  105. end
  106.  
  107. local larm = character:findFirstChild("Left Arm")
  108. local rarm = character:findFirstChild("Right Arm")
  109. function Slash(del)
  110. coroutine.resume(coroutine.create(function()
  111. local hits = {}
  112.  
  113. local start = tick()
  114. local actv = true
  115.  
  116. local function ishitted(obj)
  117. for i = 1, #hits do
  118. if obj:IsDescendantOf(hits[i]) then
  119. return true
  120. end
  121. end
  122. return false
  123. end
  124.  
  125. local function hitp(hit)
  126. if ishitted(hit) then return end
  127. local h = hit.Parent:findFirstChild("Humanoid")
  128. if h == nil then
  129. h = hit.Parent.Parent:findFirstChild("Humanoid")
  130. end
  131. if h == nil then return end
  132. hits[#hits + 1] = h.Parent
  133. HIT_HANDLE(hit, stab_damage)
  134. end
  135.  
  136. local con = {
  137. larm.Touched:connect(hitp),
  138. rarm.Touched:connect(hitp),
  139. }
  140.  
  141. while tick() - start <= Settings.Attack_speed do wait() end
  142. actv = false
  143. con[1]:disconnect()
  144. con[2]:disconnect()
  145. end))
  146. end
  147.  
  148. local dg_sounds = {
  149. equip = {
  150. "153647514"
  151. },
  152. hit = {
  153. "153647516",
  154. "153647519",
  155. "153647522",
  156. "153647526"
  157. },
  158. swing = {
  159. "153647529",
  160. "153647534",
  161. "153647539",
  162. "153647540"
  163. }
  164. }
  165.  
  166. local dg_soundobj = {}
  167. for k, v in pairs(dg_sounds) do
  168. dg_soundobj[k] = {}
  169. for i = 1, #v do
  170. local ns = Instance.new("Sound")
  171. ns.SoundId = assetlink .. v[i]
  172. ns.Volume = 1
  173. dg_soundobj[k][#dg_soundobj[k] + 1] = ns
  174. end
  175. end
  176.  
  177. function LoadSounds()
  178. for __, v in pairs(dg_soundobj) do
  179. for i = 1, #v do
  180. v[i].Parent = head
  181. end
  182. end
  183. end
  184. function RemoveSounds()
  185. for __, v in pairs(dg_soundobj) do
  186. for i = 1, #v do
  187. v[i].Parent = nil
  188. end
  189. end
  190. end
  191. function PlaySound(nm, dl)
  192. if dl == nil then
  193. dg_soundobj[nm][math.random(1, #dg_soundobj[nm])]:play()
  194. else
  195. coroutine.resume(coroutine.create(function()
  196. wait(dl)
  197. dg_soundobj[nm][math.random(1, #dg_soundobj[nm])]:play()
  198. end))
  199. end
  200. end
  201.  
  202. _G.MurderKnife_AnimType = "Default"
  203. _G.MurderKnife_AnimState = 0
  204.  
  205. function Animate(tp, st)
  206. _G.MurderKnife_AnimType = tp
  207. _G.MurderKnife_AnimState = st
  208. end
  209.  
  210. tool.Selected:connect(function(mouse) --Default, Idle1, Idle2, Attack1, Attack2
  211. humanoid.WalkSpeed = walkspeeds[2]
  212. mouse.Icon = assetlink .. "54019936"
  213. Animate("Equip", 0)
  214. LoadSounds()
  215. PlaySound("equip", 0.1)
  216.  
  217. local anim_equip = 1
  218. local last_action = tick()
  219. local idle_rand = math.random(4, 7)
  220. local idle_perform = 0
  221. local idle_type = 1
  222.  
  223. local attack_perform = 0
  224. local attack_type = 1
  225.  
  226. local running = true
  227. local last_c = tick()
  228.  
  229. local click_start = tick()
  230. mouse.Button1Down:connect(function()
  231. if not running or anim_equip > 0 then return end
  232. if tick() - attack_perform <= Settings.Attack_speed then return end
  233. attack_perform = tick()
  234. last_action = tick()
  235. attack_type = math.random(1, 3)
  236. idle_perform = 0
  237. PlaySound("swing", 0.15)
  238. Slash(0.17)
  239. end)
  240.  
  241. local conn = rs.RenderStepped:connect(function()
  242. if not running then return end
  243. local delta = tick() - last_c
  244. last_c = tick()
  245.  
  246. if anim_equip > 0 then
  247. anim_equip = math.max(0, anim_equip - (delta / Settings.Equip_time))
  248. Animate("Equip", 1 - anim_equip)
  249. elseif tick() - attack_perform <= Settings.Attack_speed then
  250. Animate("Attack" .. attack_type, (tick() - attack_perform) / Settings.Attack_speed)
  251. idle_perform = 0
  252. elseif tick() - idle_perform <= Settings.Idle_speed then
  253. Animate("Idle" .. idle_type, (tick() - idle_perform) / Settings.Idle_speed)
  254. else
  255. Animate("Default", 0)
  256. end
  257.  
  258. if tick() - last_action >= idle_rand then
  259. idle_rand = math.random(12, 20)
  260. last_action = tick()
  261. idle_perform = tick()
  262. idle_type = math.random(1, 2)
  263. end
  264.  
  265. end)
  266. tool.Deselected:connect(function() running = false conn:disconnect() end)
  267. end)
  268. tool.Deselected:connect(function()
  269. RemoveSounds()
  270. humanoid.WalkSpeed = walkspeeds[1]
  271. end)
  272.  
  273. --Murderer knife animation module, original code from The Mad Murderer, by loleris.
  274.  
  275. local mouse = pl_mouse
  276.  
  277. local conn_type = "Snap"
  278.  
  279. local anim_head = false
  280.  
  281. weapon_properties = {
  282. mesh_id = "http://www.roblox.com/asset/?id=121944778",
  283. texture_id = "http://www.roblox.com/asset/?id=121944805",
  284. scale = Vector3.new(0.6, 0.6, 0.6),
  285. transparency = 0,
  286. reflectance = 0,
  287. brick_color = BrickColor.new("Really black"),
  288. }
  289.  
  290. --How did I make all of this? Magic. Didn't even need an animation editor :)
  291. Animations = {
  292. Default = {
  293. {{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)}
  294. },
  295. Equip = {
  296. {{}, 0, CFrame.new(0, 0, 0) * CFrame.Angles(-1.571, 0, 0), CFrame.new(0, 0, 0) * CFrame.Angles(-1.571, 0, 0), CFrame.new(0, -1.3, -0.5) * CFrame.Angles(-2.618, 0, 0)},
  297. {{0.8, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.524, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  298. {{0.2, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  299. },
  300. Idle1 = {
  301. {{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  302. {{0.3, 2}, 0, CFrame.new(0.8, -0.301, 0.2) * CFrame.Angles(-0.35, 0, 0.872), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0.523, 1.221, -0.699), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 1.221, 0)},
  303. {{0.55, 2}, 0, CFrame.new(0.2, -0.5, 0.2) * CFrame.Angles(-0.14, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0, 1.221, -0.175), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.746, 1.221, 0.174)},
  304. {{0.15, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  305. },
  306. Idle2 = {
  307. {{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  308. {{0.3, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.524, 0, 0.872), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, -0.175, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0.523, 0)},
  309. {{0.3, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(0.349, 0, 0.523), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0.174, 0.698, -0.524), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, -1.222, 0)},
  310. {{0.2, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(0.61, 0, 0.349), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0.139, 0.663, -0.489), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, -1.222, 0)},
  311. {{0.2, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)}
  312. },
  313. Attack1 = {
  314. {{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  315. {{0.25, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-1.048, 0, 0.349), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0.872, 0.349, 0.087), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  316. {{0.15, 2}, 0, CFrame.new(0.4, -0.101, 0.1) * CFrame.Angles(-1.571, 0, -0.35), CFrame.new(-0.301, -0.301, 0.1) * CFrame.Angles(-1.048, -0.175, -0.524), CFrame.new(0, -1.201, -0.801) * CFrame.Angles(-2.095, 0, 0)},
  317. {{0.6, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)}
  318. },
  319. Attack2 = {
  320. {{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  321. {{0.25, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.699, 0, 0.872), CFrame.new(-0.401, 0.3, 0.1) * CFrame.Angles(1.919, 2.443, -1.222), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  322. {{0.15, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-1.048, 0, -0.524), CFrame.new(-0.5, -0.201, -0.101) * CFrame.Angles(0.523, 1.396, -0.873), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  323. {{0.6, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)}
  324. },
  325. Attack3 = {
  326. {{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  327. {{0.25, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-1.397, 0, 0.174), CFrame.new(-0.401, -0.201, 0) * CFrame.Angles(1.396, 0.698, -1.571), CFrame.new(0, -1.3, -0.401) * CFrame.Angles(-2.444, 0, 0)},
  328. {{0.15, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-1.397, 0, 0.174), CFrame.new(-0.401, 0.1, 0) * CFrame.Angles(0.349, 2.094, -0.524), CFrame.new(0, -1.3, 0.1) * CFrame.Angles(-3.84, 0, 0)},
  329. {{0.6, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)} --Psst. Create a dummy, try setting position and angles of limbs and the weapon, save CFrame data to code. Easy? Yes. When making a single knife tool, it was all you needed.
  330. }
  331. }
  332.  
  333.  
  334. function CFrameTrans(GetCFrame1, GetCFrame2, GetNumber)
  335. local Diff2 = GetCFrame2.p - GetCFrame1.p
  336. GetCFrame1_s = GetCFrame1 - GetCFrame1.p
  337. GetCFrame2 = GetCFrame2 - GetCFrame2.p
  338. local Diff = GetCFrame1_s:inverse() * GetCFrame2
  339. local x1, y1, z1 = Diff:toEulerAnglesXYZ()
  340. return (GetCFrame1 + (Diff2 * GetNumber)) * CFrame.Angles(x1 * GetNumber, y1 * GetNumber, z1 * GetNumber)
  341. end
  342.  
  343. function TransEff(x, type)
  344. if type == 1 then
  345. return x
  346. elseif type == 2 then
  347. return x*x*(3 - 2*x)
  348. elseif type == 3 then
  349. return math.sin(math.rad(x * 90))
  350. elseif type == 4 then
  351. return 1 - math.sin(math.rad((1 - x) * 90))
  352. end
  353. end
  354.  
  355. function num_trans(n1, n2, x)
  356. return n1 + ((n2 - n1) * x)
  357. end
  358.  
  359. function PlayAnimation(anim_name, tm) --return {left, right, wep, trans}
  360. tm = math.min(1, math.max(0, tm))
  361. local animd = Animations[anim_name]
  362. if #animd == 1 then
  363. return {animd[1][3], animd[1][4], animd[1][5], animd[1][2]}
  364. else
  365. local trans_from = 1
  366. local trans_to = 1
  367. local tm_left = tm
  368. for i = 2, #animd do
  369. tm_left = tm_left - animd[i][1][1]
  370. if tm_left <= 0 then
  371. trans_from = i - 1
  372. trans_to = i
  373. break
  374. end
  375. end
  376. local trans_amm = TransEff((animd[trans_to][1][1] + tm_left) / animd[trans_to][1][1], animd[trans_to][1][2])
  377. return {
  378. CFrameTrans(animd[trans_from][3], animd[trans_to][3], trans_amm),
  379. CFrameTrans(animd[trans_from][4], animd[trans_to][4], trans_amm),
  380. CFrameTrans(animd[trans_from][5], animd[trans_to][5], trans_amm),
  381. num_trans(animd[trans_from][2], animd[trans_to][2], trans_amm)
  382. }
  383. end
  384. end
  385.  
  386. rot_amplitude_head = 20
  387. rot_amplitude_chest = 15
  388.  
  389. anim_p = {
  390. cam_offset = CFrame.new(0.2, -0.37, 0.91) * CFrame.Angles(math.rad(0), math.rad(0), math.rad(0)),
  391. aim_amp = 0.5,
  392. aim_max_change = 4,
  393. aim_retract = 15,
  394. aim_max_deg = 20,
  395. }
  396.  
  397. local weapon_model = Instance.new("Part")
  398. weapon_model.CanCollide = false
  399. weapon_model.Name = "WeaponObject"
  400. weapon_model.formFactor = "Custom"
  401. weapon_model.Size = Vector3.new(0.2, 0.2, 0.2)
  402. weapon_model.TopSurface = 0
  403. weapon_model.BottomSurface = 0
  404. weapon_model.BrickColor = weapon_properties.brick_color
  405. weapon_model.Transparency = weapon_properties.transparency
  406. weapon_model.Reflectance = weapon_properties.reflectance
  407. local mesh = Instance.new("SpecialMesh", weapon_model)
  408. mesh.Scale = weapon_properties.scale
  409. mesh.MeshId = weapon_properties.mesh_id
  410. mesh.TextureId = weapon_properties.texture_id
  411.  
  412. torso = character.Torso
  413. head = character.Head
  414.  
  415. motors = {torso:findFirstChild("Left Shoulder"), torso:findFirstChild("Right Shoulder"), torso:findFirstChild("Neck")}
  416. welds = {nil, nil, nil}
  417. weapon_parts = {weapon_model:clone(), weapon_model:clone()}
  418. weapon_model = nil
  419.  
  420. function EndAnimation()
  421. if motors[1] then
  422. motors[1].Part1 = character:findFirstChild("Left Arm")
  423. end
  424. if motors[2] then
  425. motors[2].Part1 = character:findFirstChild("Right Arm")
  426. end
  427. if motors[3] then
  428. motors[3].Part1 = character:findFirstChild("Head")
  429. end
  430. if welds[1] then
  431. welds[1]:remove()
  432. welds[1] = nil
  433. end
  434. if welds[2] then
  435. welds[2]:remove()
  436. welds[2] = nil
  437. end
  438. if welds[3] then
  439. welds[3]:remove()
  440. welds[3] = nil
  441. end
  442. weapon_parts[1].Parent = nil
  443. if weapon_model then
  444. weapon_model.Parent = nil
  445. end
  446. coroutine.resume(coroutine.create(function()
  447. local swm = weapon_model
  448. wait()
  449. swm.Parent = nil
  450. wait(0.1)
  451. swm.Parent = nil
  452. wait(0.5)
  453. swm.Parent = nil
  454. end))
  455. end
  456.  
  457. local anim_model = Instance.new("Model")
  458. anim_model.Name = "WeaponAnimation"
  459. weapon_model = anim_model
  460.  
  461. local cam_larm = Instance.new("Part")
  462. cam_larm.Parent = anim_model
  463. cam_larm.BrickColor = BrickColor.new("Really black")
  464. cam_larm.formFactor = "Custom"
  465. cam_larm.Size = Vector3.new(0.2, 0.2, 0.2)
  466. cam_larm.TopSurface = 0
  467. cam_larm.BottomSurface = 0
  468. cam_larm.Transparency = 0.4
  469. cam_larm.CanCollide = false
  470. local hmesh = Instance.new("BlockMesh", cam_larm)
  471. hmesh.Scale = Vector3.new(5, 10, 5)
  472.  
  473. local cam_rarm = cam_larm:clone()
  474. cam_rarm.Parent = anim_model
  475.  
  476. function StartAnimation()
  477. local check = {torso:findFirstChild("LeftWeld"), torso:findFirstChild("RightWeld"), torso:findFirstChild("HeadWeld")}
  478. if check[1] then check[1]:remove() end
  479. if check[2] then check[2]:remove() end
  480. if check[3] then check[3]:remove() end
  481. local check2 = {character:findFirstChild("WeaponObject"), camera:findFirstChild("WeaponAnimation")}
  482. if check2[1] then check2[1].Parent = nil end
  483. if check2[2] then check2[2].Parent = nil end
  484. if motors[1] then
  485. motors[1].Part1 = nil
  486. end
  487. if motors[2] then
  488. motors[2].Part1 = nil
  489. end
  490. if motors[3] then
  491. motors[3].Part1 = nil
  492. end
  493. welds = {Instance.new(conn_type), Instance.new(conn_type), Instance.new(conn_type)}
  494. welds[1].Part0 = torso
  495. welds[2].Part0 = torso
  496. welds[3].Part0 = torso
  497. welds[1].Part1 = character:findFirstChild("Left Arm")
  498. welds[2].Part1 = character:findFirstChild("Right Arm")
  499. welds[3].Part1 = character:findFirstChild("Head")
  500. welds[1].Name = "LeftWeld"
  501. welds[2].Name = "RightWeld"
  502. welds[2].Name = "HeadWeld"
  503. welds[1].C0 = CFrame.new(-1.5, 0, 0)
  504. welds[2].C0 = CFrame.new(1.5, 0, 0)
  505. welds[3].C0 = CFrame.new(0, 1.5, 0)
  506. welds[1].Parent = torso
  507. welds[2].Parent = torso
  508. welds[3].Parent = torso
  509.  
  510. weapon_parts[1].Parent = character
  511. local wep_weld = Instance.new(conn_type)
  512. wep_weld.Part0 = character:findFirstChild("Right Arm")
  513. wep_weld.Part1 = weapon_parts[1]
  514. wep_weld.C0 = CFrame.new()
  515. wep_weld.Parent = weapon_parts[1]
  516.  
  517. local weld1 = welds[1]
  518. local weld2 = welds[2]
  519. local weld3 = welds[3]
  520.  
  521. local cam_welds = {Instance.new(conn_type), Instance.new(conn_type), Instance.new(conn_type)}
  522. cam_welds[1].Part0 = torso
  523. cam_welds[1].Part1 = cam_larm
  524. cam_welds[1].Parent = cam_larm
  525. cam_welds[2].Part0 = torso
  526. cam_welds[2].Part1 = cam_rarm
  527. cam_welds[2].Parent = cam_rarm
  528. cam_welds[3].Part0 = cam_rarm
  529. cam_welds[3].Part1 = weapon_parts[2]
  530. cam_welds[3].Parent = weapon_parts[2]
  531. weapon_parts[2].Parent = anim_model
  532.  
  533. local move_anim_speed = 3
  534. local last_p = Vector3.new()
  535. local move_amm = 0
  536. coroutine.resume(coroutine.create(function()
  537. while weld1.Parent ~= nil do
  538. local delta = wait(1/25)
  539. local cur_p = torso.Position
  540. if (cur_p - last_p).magnitude >= 0.1 then
  541. move_amm = math.min(1, move_amm + delta * move_anim_speed)
  542. else
  543. move_amm = math.max(0, move_amm - delta * move_anim_speed)
  544. end
  545. last_p = cur_p
  546. end
  547. end))
  548.  
  549. local r_serv = game:GetService("RunService")
  550.  
  551. --EASTER EGG
  552. function easein(x)
  553. return math.sin(math.rad(x * 90))
  554. end
  555.  
  556. local a_horse = (character:findFirstChild("HorseHead") ~= nil)
  557. local horse_displace = {0, 0}
  558. local horse_cf = CFrame.Angles(0.0001, 0.0001, 0)
  559. if a_horse then
  560. coroutine.resume(coroutine.create(function()
  561. while weld1.Parent ~= nil do
  562. local rndwait = (math.random(100, 1000) / 1000) * 4
  563. wait(rndwait)
  564. local oldd = {horse_displace[1], horse_displace[2]}
  565. local disp2 = {math.random(-60, 60), math.random(0, 25)}
  566.  
  567. local ld = 0
  568. while ld ~= 1 do
  569. local st = tick()
  570. r_serv.RenderStepped:wait()
  571. ld = math.min(1, ld + ((tick() - st) * 4))
  572. local eff = easein(ld)
  573.  
  574. local x = oldd[1] - ((oldd[1] - disp2[1]) * eff)
  575. local y = oldd[2] - ((oldd[2] - disp2[2]) * eff)
  576. horse_displace = {x, y}
  577. horse_cf = CFrame.Angles(math.rad(y), math.rad(x) , 0)
  578. end
  579. end
  580. end))
  581. end
  582.  
  583. --EASTER EGG
  584.  
  585. local last_va = 0
  586. local last_va2 = 0
  587. local view_velocity = {0, 0}
  588.  
  589. coroutine.resume(coroutine.create(function()
  590. local last_time = tick()
  591. while weld1.Parent ~= nil do
  592. r_serv.RenderStepped:wait() ------------------------------------------------
  593. local delta = tick() - last_time
  594. last_time = tick()
  595.  
  596. local breathe_amp = 2
  597. local breathe_freq = 0.8
  598. local breathe = math.sin(math.rad(tick() * 90 * breathe_freq)) * breathe_amp
  599.  
  600. local shake_freq = 5
  601. local shake_amp = {0.05, 0.05}
  602. local arm_shake = CFrame.new(
  603. math.sin(math.rad(tick() * 90 * shake_freq)) * move_amm * shake_amp[1],
  604. 0,
  605. math.abs(math.sin(math.rad(tick() * 90 * shake_freq)) * move_amm * shake_amp[2]))
  606.  
  607.  
  608. --ANIMATION LOOP
  609. local p_distance = (head.Position - mouse.Hit.p).magnitude
  610. if p_distance == 0 then p_distance = 0.0001 end
  611. local p_height = mouse.Hit.p.y - head.Position.y
  612. local view_angle
  613. if p_height ~= 0 then
  614. view_angle = math.deg(math.asin(math.abs(p_height) / p_distance)) * (math.abs(p_height) / p_height)
  615. else
  616. view_angle = 0
  617. end
  618.  
  619. local cam_cf = camera.CoordinateFrame
  620. local looking_at = cam_cf * CFrame.new(0, 0, -100)
  621. local view_angle2 = math.deg(math.atan2(cam_cf.p.x - looking_at.p.x, cam_cf.p.z - looking_at.p.z)) + 180
  622.  
  623. local v_delta1, v_delta2
  624. local dir1 = 0
  625. local dir2 = 0
  626. v_delta1 = math.abs(view_angle - last_va)
  627. if v_delta1 ~= 0 then
  628. dir1 = (view_angle - last_va) / v_delta1
  629. end
  630. local va_check = {math.abs(view_angle2 - last_va2), 360 - math.abs(view_angle2 - last_va2)}
  631. if view_angle2 == last_va2 then
  632. dir2 = 0
  633. v_delta2 = 0
  634. elseif va_check[1] < va_check[2] then
  635. v_delta2 = va_check[1]
  636. dir2 = (view_angle2 - last_va2) / va_check[1]
  637. else
  638. v_delta2 = va_check[2]
  639. if last_va2 > view_angle2 then
  640. dir2 = 1
  641. else
  642. dir2 = -1
  643. end
  644. end
  645. last_va = view_angle
  646. last_va2 = view_angle2
  647.  
  648. view_velocity[1] = view_velocity[1] / (1 + (delta * anim_p.aim_retract))
  649. view_velocity[2] = view_velocity[2] / (1 + (delta * anim_p.aim_retract))
  650.  
  651. local calc1 = v_delta1 * dir1 * anim_p.aim_amp
  652. if calc1 ~= 0 then
  653. view_velocity[1] = view_velocity[1] + (math.min(anim_p.aim_max_change, math.abs(calc1)) * (calc1 / math.abs(calc1)))
  654. end
  655. local calc2 = v_delta2 * dir2 * anim_p.aim_amp
  656. if calc2 ~= 0 then
  657. view_velocity[2] = view_velocity[2] + (math.min(anim_p.aim_max_change, math.abs(calc2)) * (calc2 / math.abs(calc2)))
  658. end
  659.  
  660. if view_velocity[1] ~= 0 then
  661. view_velocity[1] = math.min(anim_p.aim_max_deg, math.abs(view_velocity[1])) * (math.abs(view_velocity[1]) / view_velocity[1])
  662. end
  663. if view_velocity[2] ~= 0 then
  664. view_velocity[2] = math.min(anim_p.aim_max_deg, math.abs(view_velocity[2])) * (math.abs(view_velocity[2]) / view_velocity[2])
  665. end
  666.  
  667. local anmtp = _G.MurderKnife_AnimType
  668. local anmst = _G.MurderKnife_AnimState
  669.  
  670. if anmst == nil then
  671. anmst = 0
  672. end
  673.  
  674. if anmtp ~= nil then
  675. if Animations[anmtp] == nil then
  676. anmtp = "Default"
  677. end
  678. else
  679. anmtp = "Default"
  680. end
  681. local curr_anim = PlayAnimation(anmtp, anmst) --left, right, weapon, wep trans
  682.  
  683. --curr_anim = {Animations.Default[1][3], Animations.Default[1][4], Animations.Default[1][5], 0}
  684.  
  685. local chestCF = CFrame.new(0, 0.5, 0) * CFrame.Angles(math.rad(math.max(-rot_amplitude_chest, math.min(rot_amplitude_chest, view_angle)) + 90 + breathe), 0, 0)
  686. weld1.C1 = (chestCF * curr_anim[1] * CFrame.new(0, -0.5, 0)):inverse()
  687. weld2.C1 = (chestCF * curr_anim[2] * CFrame.new(0, -0.5, 0)):inverse()
  688. wep_weld.C1 = (curr_anim[3]):inverse()
  689. weapon_parts[1].Transparency = curr_anim[4]
  690. if anim_head then
  691. weld3.C1 = (CFrame.new(0, 0, 0) * CFrame.Angles(math.rad(math.max(-rot_amplitude_head, math.min(rot_amplitude_head, view_angle))), 0, 0) * horse_cf):inverse()
  692. else
  693. weld3.C1 = (CFrame.new(0, 0, 0)):inverse()
  694. end
  695.  
  696. if (head.Position - camera.CoordinateFrame.p).magnitude < 3 then
  697. if anim_model.Parent == nil then
  698. anim_model.Parent = camera
  699. end
  700. cam_welds[1].Parent = cam_larm
  701. cam_welds[2].Parent = cam_rarm
  702. cam_welds[3].Parent = weapon_parts[2]
  703. local cam_cf = camera.CoordinateFrame * CFrame.Angles(math.rad(90 + (breathe / 2) - view_velocity[1]), 0, math.rad(view_velocity[2])) * arm_shake * anim_p.cam_offset
  704. cam_welds[1].C1 = (torso.CFrame:inverse() * cam_cf * CFrame.new(-1.5, 0, 0) * curr_anim[1] * CFrame.new(0, -0.5, 0)):inverse()
  705. cam_welds[2].C1 = (torso.CFrame:inverse() * cam_cf * CFrame.new(1.5, 0, 0) * curr_anim[2] * CFrame.new(0, -0.5, 0)):inverse()
  706. cam_welds[3].C1 = (curr_anim[3]):inverse()
  707. weapon_parts[2].Transparency = curr_anim[4]
  708. else
  709. if anim_model.Parent ~= nil then
  710. anim_model.Parent = nil
  711. end
  712. end
  713. --ANIMATION LOOP
  714. end
  715. end))
  716. end
  717.  
  718. local last_st = 0
  719. local eq = false
  720. tool.Selected:connect(function(mouse)
  721. if eq then return end
  722. eq = true
  723. wait()
  724. StartAnimation()
  725. end)
  726.  
  727. tool.Deselected:connect(function()
  728. eq = false
  729. EndAnimation()
  730. end)
  731.  
  732. --[[
  733. Smith and Wesson M&P 45, chambered in .45 ACP ammunition.
  734. The standard magazine holds 10 rounds, although magazines that could hold 14 rounds were also made but looked incredibly stupid.
  735. Credit to litozinnamon for the crosshairs and bullethole decals. I used them without permission. Not like I asked him, anyhow.
  736. ]]
  737.  
  738. plr=game:service'Players'.LocalPlayer
  739. ch,char=plr.Character,plr.Character
  740. hum=ch.Humanoid
  741. tor,torso,rootpart,rj=ch.Torso,ch.Torso,ch.HumanoidRootPart,ch.HumanoidRootPart.RootJoint
  742. m,mouse=plr:GetMouse(),plr:GetMouse()
  743. cfn,ang,mr,int=CFrame.new,CFrame.Angles,math.rad,Instance.new
  744. bc=BrickColor.new
  745. head=ch.Head
  746. cam=workspace.CurrentCamera
  747.  
  748. rj.C0=cfn()
  749. rj.C1=cfn()
  750.  
  751. sheathed=false
  752. jammed=false
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764. local minimumsize = Vector3.new(0.7,0.7,0.7) --Minimumsize for a part to get divided,higher numbers = less detailed and bigger/less bricks
  765. local surface_between_splitted_parts = 'SmoothNoOutlines' --the surface between splitted parts
  766. --local fragmented = workspace:FindFirstChild("Fragmented")
  767. local fragmentable = workspace --all fragmentable objects should be stored in here
  768. local list = {}
  769. local brickcount = 0
  770. --local m = Instance.new("Hint",workspace)
  771. local storage = {}
  772. local fillup = 1000 --it constantly generates new parts until it reaches this number(hacky way to prevent lagspikes if there is a large explosion),change it to 0 if you don´t want it to generate (useless) parts.
  773. local maximumstorage = 2000 --it will recycle parts if the number of parts in the storage doesnt exceed this number
  774. local storage_position = Vector3.new(0,0,5000) --place them somewhere off the map
  775. local stored_partsize = Vector3.new(1,1,1) --make them small
  776. local parts_created_per_frame = 5 --number of parts being created per frame to fill up the storage
  777.  
  778.  
  779. function fragmentate(cframe,size,color,explosion_position,explosion_blastradius,backsurface,bottomsurface,frontsurface,leftsurface,rightsurface,topsurface,transparency,reflectance)
  780. local xi = size.X >= minimumsize.X*(1+explosion_blastradius/16) and 2 or 1 --to reduce the lagg in large explosions we increase minimumsize based on the explosionradius...
  781. local yi = size.Y >= minimumsize.Y*(1+explosion_blastradius/16) and 2 or 1
  782. local zi = size.Z >= minimumsize.Z*(1+explosion_blastradius/16) and 2 or 1
  783. if xi == 1 and yi == 1 and zi == 1 or (cframe.p-explosion_position).magnitude > size.magnitude/2 + explosion_blastradius then --don´t fragmentate parts, that are too small to fragmentate or too far away from the explosion
  784. if xi == 1 and yi == 1 and zi == 1 then return end --optional
  785. if #storage > 0 then
  786. local p = storage[1]
  787. p.BrickColor = color
  788. p.Size = size
  789. p.BackSurface = backsurface
  790. p.BottomSurface = bottomsurface
  791. p.FrontSurface = frontsurface
  792. p.LeftSurface = leftsurface
  793. p.RightSurface = rightsurface
  794. p.TopSurface = topsurface
  795. p.Transparency = transparency
  796. p.CFrame = cframe
  797. p.Reflectance = reflectance
  798. table.remove(storage,1)
  799. else
  800. local p = Instance.new("Part",fragmentable)
  801. p.BrickColor = color
  802. p.FormFactor = "Custom"
  803. p.Size = size
  804. p.BackSurface = backsurface
  805. p.BottomSurface = bottomsurface
  806. p.FrontSurface = frontsurface
  807. p.LeftSurface = leftsurface
  808. p.RightSurface = rightsurface
  809. p.TopSurface = topsurface
  810. p.Transparency = transparency
  811. if p.Transparency>0.285 then
  812. p.Anchored = false
  813. else
  814. p.Anchored=true
  815. p.Material='Wood'
  816. end
  817. p.CFrame = cframe
  818. p.Reflectance = reflectance
  819. end
  820. --p:MakeJoints()
  821. -- m.Text = m.Text+1
  822. return --stop the function
  823. end
  824. local mody = math.random(-125,125)/1000 --some randomization
  825. for y = 1,yi do
  826. if math.random()> 0.5 then
  827. local modx = math.random(-125,125)/1000
  828. for x = 1,xi do
  829. local modz = math.random(-125,125)/1000
  830. for z = 1,zi do --offset = x/xi-0.75+modx)
  831. fragmentate(cframe*CFrame.new(size.X*(xi==1 and 0 or x/xi-0.75+modx),size.Y*(yi==1 and 0 or y/yi-0.75+mody),size.Z*(zi==1 and 0 or z/zi-0.75+modz)), --maths
  832. Vector3.new(xi == 2 and size.X*(1-2*math.abs(x/xi-0.75+modx)) or size.X,yi == 2 and size.Y*(1-2*math.abs(y/yi-0.75+mody)) or size.Y,
  833. zi == 2 and size.Z*(1-2*math.abs(z/zi-0.75+modz)) or size.Z or agent767_was_here),color,explosion_position,explosion_blastradius,
  834. z~=zi and surface_between_splitted_parts or backsurface,y==2 and surface_between_splitted_parts or bottomsurface,
  835. z==2 and surface_between_splitted_parts or frontsurface,x==2 and surface_between_splitted_parts or leftsurface,x~=xi and surface_between_splitted_parts or rightsurface,
  836. y~=yi and surface_between_splitted_parts or topsurface,transparency,reflectance)
  837. end
  838.  
  839. end
  840. else
  841. local modz = math.random(-125,125)/1000
  842. for z = 1,zi do
  843. local modx = math.random(-125,125)/1000
  844. for x = 1,xi do
  845. fragmentate(cframe*CFrame.new(size.X*(xi==1 and 0 or x/xi-0.75+modx),size.Y*(yi==1 and 0 or y/yi-0.75+mody),size.Z*(zi==1 and 0 or z/zi-0.75+modz)),
  846. Vector3.new(xi == 2 and size.X*(1-2*math.abs(x/xi-0.75+modx)) or size.X,yi == 2 and size.Y*(1-2*math.abs(y/yi-0.75+mody)) or size.Y,
  847. zi == 2 and size.Z*(1-2*math.abs(z/zi-0.75+modz)) or size.Z),color,explosion_position,explosion_blastradius,
  848. z~=zi and surface_between_splitted_parts or backsurface,y==2 and surface_between_splitted_parts or bottomsurface,
  849. z==2 and surface_between_splitted_parts or frontsurface,x==2 and surface_between_splitted_parts or leftsurface,x~=xi and surface_between_splitted_parts or rightsurface,
  850. y~=yi and surface_between_splitted_parts or topsurface,transparency,reflectance)
  851. end
  852. end
  853. end
  854. end
  855. end
  856.  
  857. function start_fragmentation(position,radius)
  858. local search = Region3.new(position-Vector3.new(radius,radius,radius)*1.1,position+Vector3.new(radius,radius,radius)*1.1)
  859. repeat
  860. local finish = false
  861. local parts = workspace:FindPartsInRegion3WithIgnoreList(search,list,100) --maximum number of parts that FindPartsInRegion3 can find is 100, so we have to do this to find them all
  862. for i = 1,#parts do
  863. table.insert(list,1,parts[i])
  864. end
  865. finish = true
  866. until #parts < 100 and finish
  867. print(#list)
  868. local t = tick()
  869. for i = 1,#list do
  870. local p = list[i]
  871. if p:IsDescendantOf(fragmentable) and p:GetMass()<3000 and p.Transparency>0.285 and p.Name~='Base' and p:IsDescendantOf(ch)==false then
  872. fragmentate(p.CFrame,p.Size,p.BrickColor,position,radius,p.BackSurface,p.BottomSurface,p.FrontSurface,p.LeftSurface,p.RightSurface,p.TopSurface,p.Transparency,p.Reflectance)
  873. if #storage < maximumstorage and p.Shape == "Block" then --recycle them
  874. p.Anchored = false
  875. p.FormFactor = "Custom"
  876. p.Size = stored_partsize
  877. p.Position = storage_position
  878. table.insert(storage,1,p)
  879. else --storage is full
  880. p:Destroy()
  881. end
  882. -- m.Text = m.Text-1
  883. end
  884. if p:IsDescendantOf(fragmentable) and p:GetMass()<53000 and p.Transparency<0.05 and p.Name~='Base' and tostring(p.Material)=='Enum.Material.Wood' and p:IsDescendantOf(ch)==false then
  885. fragmentate(p.CFrame,p.Size,p.BrickColor,position,radius,p.BackSurface,p.BottomSurface,p.FrontSurface,p.LeftSurface,p.RightSurface,p.TopSurface,p.Transparency,p.Reflectance)
  886. if #storage < maximumstorage and p.Shape == "Block" then --recycle them
  887. p.Anchored = true
  888. p.Material='Wood'
  889. p.FormFactor = "Custom"
  890. p.Size = stored_partsize
  891. p.Position = storage_position
  892. table.insert(storage,1,p)
  893. else --storage is full
  894. p:Destroy()
  895. end
  896. -- m.Text = m.Text-1
  897. end
  898. end
  899. list = {}
  900. -- print(tick()-t)
  901. end
  902.  
  903. --[[
  904. spawn(function()
  905. while wait() do --oh noes,a loop! So inefficient!
  906. if #storage < fillup then
  907. for i = 1, parts_created_per_frame do --creates parts to fill up the storage
  908. local p = Instance.new("Part",fragmentable)
  909. p.Anchored = false
  910. p.FormFactor = "Custom"
  911. p.Size = stored_partsize
  912. p.Position = storage_position
  913. table.insert(storage,1,p)
  914. end
  915. end
  916. end
  917. end)
  918. ]]
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942. --local blankn=22416261
  943.  
  944. --172121567
  945.  
  946. crosshairs={
  947. {38140824};
  948. {38140833};
  949. {38140839};
  950. {38140843};
  951. {38140852};
  952. {38140910};
  953. {38140915};
  954. {38140923};
  955. {38140928};
  956. {38140931};
  957. {38208259};
  958. {38208275};
  959. {38208284};
  960. {38208303};
  961. {38208310};
  962. {38208325};
  963. {38208330};
  964. {38208352};
  965. {38208359};
  966. {38208377}
  967. }
  968.  
  969. bulletholes={
  970. 172274695;
  971. 172274721
  972. }
  973.  
  974. for _,v in pairs(crosshairs) do
  975. game:service'ContentProvider':Preload('rbxassetid://' .. tostring(v[1]-1))
  976. end
  977.  
  978. currentIco=2
  979. switchIco=function(num)
  980. if num<20 then
  981. else
  982. num=20
  983. end
  984. mouse.Icon='rbxassetid://' .. tostring(crosshairs[num][1]-1)
  985. currentIco=num
  986. end
  987.  
  988. switchIco(currentIco)
  989.  
  990. heldDown=false
  991.  
  992. spreadint=1
  993. --[[Settings]]--
  994. recoil=false -- Set to true for added realism
  995. magCapacity=20 -- How much a magazine can hold at once
  996. magAmmo=20 -- How much ammo is in the mag
  997. crosshairSpread=5
  998. spread=1
  999. pAmmunition=true -- more damage if true
  1000.  
  1001.  
  1002. jamRate=500 -- How often the gun jams(the more the less) (no less than 1)
  1003.  
  1004. primaryColor='Really black'
  1005. secondaryColor='Really black'
  1006.  
  1007. slideReflectance=0.01
  1008. slideMaterial='Plastic'
  1009.  
  1010. --[[Attachments]]--
  1011.  
  1012. silencer=true
  1013. highCapMag=false -- High capacity magazine
  1014. laser=true
  1015. automatic=false
  1016. grip=true
  1017.  
  1018.  
  1019. getSound=function(id)
  1020. game:service'ContentProvider':Preload('rbxassetid'..tostring(id))
  1021. local s=int("Sound",ch.Head)
  1022. s.SoundId='rbxassetid://' .. tostring(id)
  1023. s.Volume=1
  1024. return s
  1025. end
  1026.  
  1027. local fireSound=getSound(151997297--[[10209842]])
  1028. fireSound.Pitch=1.3
  1029. --1.8
  1030.  
  1031. local releaseSound=getSound(10209813)
  1032. releaseSound.Pitch=4
  1033.  
  1034. local reloadSound=getSound(10209636)
  1035. reloadSound.Pitch=3
  1036.  
  1037. local magazinelockSound=getSound(152206337)
  1038. magazinelockSound.Pitch=1.4
  1039.  
  1040. local slideBackSound=getSound(152206263)
  1041. slideBackSound.Pitch=2.5
  1042.  
  1043. local slideForwardSound=getSound(152206302)
  1044. slideForwardSound.Pitch=2.5
  1045.  
  1046. local emptySound=getSound(2697295)
  1047. emptySound.Pitch=5
  1048.  
  1049. local glassBreakSound=getSound(144884907)
  1050.  
  1051. local woodImpact=getSound(142082171)
  1052.  
  1053. local fleshImpact=getSound(144884872)
  1054. fleshImpact.Pitch=1.7
  1055.  
  1056. if ch:findFirstChild("Tec-99") then
  1057. ch['Tec-99']:Destroy()
  1058. end
  1059.  
  1060. local tube=int("Model",ch)
  1061. tube.Name='Tec-99'
  1062. local hopper=Instance.new('HopperBin',plr.Backpack)
  1063. hopper.Name=tube.Name
  1064. Weld = function(p0,p1,x,y,z,rx,ry,rz,par)--recommend to use this with my weld. use this function only with arm lockers.
  1065. p0.Position = p1.Position
  1066. local w = Instance.new('Motor',par or p0)
  1067. w.Part0 = p1
  1068. w.Part1 = p0
  1069. w.C0 = CFrame.new(x or 0,y or 0,z or 0)*CFrame.Angles(rx or 0,ry or 0,rz or 0)
  1070. w.MaxVelocity = .1
  1071. return w
  1072. end
  1073. function clerp(c1,c2,sp)
  1074. local R1,R2,R3 = c1:toEulerAnglesXYZ()
  1075. local R21,R22,R23 = c2:toEulerAnglesXYZ()
  1076. return CFrame.new(
  1077. c1.X + (c2.X-c1.X)*sp,
  1078. c1.Y + (c2.Y-c1.Y)*sp,
  1079. c1.Z + (c2.Z-c1.Z)*sp)*CFrame.Angles(
  1080. R1 + (R21-R1)*sp,
  1081. R2 + (R22-R2)*sp,
  1082. R3 + (R23-R3)*sp
  1083. )
  1084. end
  1085.  
  1086. tweenTable={}
  1087. Tween = function(Weld, Stop, Step,a)
  1088. ypcall(function()
  1089. local func = function()
  1090. local Start = Weld.C1
  1091. local X1, Y1, Z1 = Start:toEulerAnglesXYZ()
  1092. local Stop = Stop
  1093. local X2, Y2, Z2 = Stop:toEulerAnglesXYZ()
  1094. if not Step then Step=0.1 end
  1095. table.insert(tweenTable,{th=0,Weld=Weld,Step=Step,Start=Start,X1=X1,Y1=Y1,Z1=Z1,Stop=Stop,X2=X2,Y2=Y2,Z2=Z2})
  1096. end
  1097. if a then coroutine.wrap(func)() else func() end
  1098. end)
  1099. end
  1100. weld=function(p0,p1,c0)
  1101. local w=Instance.new("Weld",p0)
  1102. w.Part0=p0
  1103. w.Part1=p1
  1104. w.C0=c0
  1105. return w
  1106. end
  1107. cp=function(parent,color,size,anchored,cancollide)
  1108. local newp=Instance.new("Part",parent)
  1109. newp.TopSurface='SmoothNoOutlines'
  1110. newp.BottomSurface='SmoothNoOutlines'
  1111. newp.FrontSurface='SmoothNoOutlines'
  1112. newp.BackSurface='SmoothNoOutlines'
  1113. newp.RightSurface='SmoothNoOutlines'
  1114. newp.LeftSurface='SmoothNoOutlines'
  1115. newp.FormFactor="Custom"
  1116. newp.BrickColor=bc(color)
  1117. newp.Size=size
  1118. newp.Anchored=anchored
  1119. newp.CanCollide=cancollide
  1120. newp:BreakJoints()
  1121. return newp
  1122. end
  1123.  
  1124. initializeJoints=function()
  1125. rabr = cp(tube,'White',Vector3.new(1,1,1),false,false) rabr.Transparency = 1 rabr.Name='Locker'
  1126. rabr.Position = torso.Position
  1127. rw = Weld(rabr,torso,1.5,.5,0,0,0,0) rw.Parent = tube rw.Name = 'rw'
  1128. w = Instance.new("Weld",tube)
  1129. w.Part0,w.Part1 = ch['Right Arm'],rabr
  1130. w.C1 = CFrame.new(0,-.5,0)
  1131. labr = cp(tube,'White',Vector3.new(1,1,1),false,false) labr.Transparency = 1 labr.Name='Locker'
  1132. labr.Position = torso.Position
  1133. lw = Weld(labr,torso,-1.5,.5,0,0,0,0) lw.Parent = tube lw.Name = 'lw'
  1134. ww = Instance.new("Weld",tube)
  1135. ww.Part0,ww.Part1 = ch['Left Arm'],labr
  1136. ww.C1 = CFrame.new(0,-.5,0)
  1137. end
  1138.  
  1139. initializeJoints()
  1140.  
  1141. --[[ leg locks
  1142. rabl = cp(tube,'White',Vector3.new(1,1,1),false,false) rabl.Transparency = 1 rabl.Name='Locker'
  1143. rabl.Position = torso.Position
  1144. rwl = Weld(rabl,torso,0.5,-1.5,0,0,0,0) rwl.Parent = tube rwl.Name = 'rwl'
  1145. wl = Instance.new("Weld",tube)
  1146. wl.Part0,wl.Part1 = ch['Right Leg'],rabl
  1147. wl.C1 = CFrame.new(0,-.5,0)
  1148. labl = cp(tube,'White',Vector3.new(1,1,1),false,false) labl.Transparency = 1 labl.Name='Locker'
  1149. labl.Position = torso.Position
  1150. lwl = Weld(labl,torso,-0.5,-1.5,0,0,0,0) lwl.Parent = tube lwl.Name = 'lwl'
  1151. wwl = Instance.new("Weld",tube)
  1152. wwl.Part0,wwl.Part1 = ch['Left Leg'],labl
  1153. wwl.C1 = CFrame.new(0,-.5,0)
  1154. ]]
  1155. --weld(ch['HumanoidRootPart'],torso,cfn())
  1156.  
  1157.  
  1158. local counter=Instance.new('ScreenGui',plr.PlayerGui)
  1159. local frame=Instance.new('Frame',counter)
  1160. frame.Size=UDim2.new(0.25,0,0.3,0)
  1161.  
  1162. frame.Position=UDim2.new(0.1,0,0.4,0)
  1163. frame.BackgroundTransparency=1
  1164.  
  1165. local ammocounter=Instance.new('TextLabel',frame)
  1166. ammocounter.Size=UDim2.new(1,0,0.3,0)
  1167. ammocounter.Position=UDim2.new(0,0,0.2,0)
  1168. ammocounter.BackgroundTransparency=1
  1169. ammocounter.TextColor3=BrickColor.new('White').Color
  1170. ammocounter.Font='SourceSansBold'
  1171. ammocounter.FontSize='Size18'
  1172. ammocounter.Text=''
  1173. ammocounter.TextXAlignment='Left'
  1174.  
  1175.  
  1176. local bg = Instance.new("BodyGyro",rootpart)
  1177. bg.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
  1178. bg.P = 10000
  1179. bg.D = 100
  1180.  
  1181.  
  1182. cyl=function(prt)
  1183. local c=int("CylinderMesh",prt)
  1184. return c
  1185. end
  1186. blo=function(prt)
  1187. local c=int("BlockMesh",prt)
  1188. return c
  1189. end
  1190.  
  1191. if laser then
  1192. aLaser=cp(tube,'Really red',Vector3.new(0.2,0.2,0.2))
  1193. aLaser.Transparency=1
  1194. cyl(aLaser).Scale=Vector3.new(0.25,1,0.25)
  1195. aLaser.Anchored=true
  1196. end
  1197.  
  1198. local handle=cp(tube,primaryColor,Vector3.new(0.2,0.6,0.3))
  1199. blo(handle).Scale=Vector3.new(1.15,0.9,1)
  1200. local mw=weld(ch['Right Arm'],handle,cfn(-0.4,-1,-0.19)*ang(mr(-101.5),0,0)*cfn()*ang(0,mr(-30),mr(-5)))
  1201.  
  1202. local framepiece1=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.9))
  1203. blo(framepiece1).Scale=Vector3.new(1.15,0.5,1)
  1204. weld(handle,framepiece1,cfn(0,0.354,-0.3)*ang(mr(11.5),0,0))
  1205.  
  1206. local barrel=cp(tube,'Medium stone grey',Vector3.new(0.2,0.2,0.2))
  1207. cyl(barrel).Scale=Vector3.new(0.7,1.2,0.7)
  1208. weld(framepiece1,barrel,cfn(0,0.15,-0.1)*ang(mr(-90),0,0))
  1209.  
  1210. local sbarrel=cp(tube,'Really black',Vector3.new(0.2,0.3,0.2))
  1211. cyl(sbarrel).Scale=Vector3.new(0.7,1.5,0.7)
  1212. weld(barrel,sbarrel,cfn(0,0.35,0))
  1213. local hole=cp(tube,'White',Vector3.new(0.2,0.2,0.2))
  1214. hole.Transparency=1
  1215. weld(sbarrel,hole,cfn(0,0.2,0))
  1216. local flash=int('PointLight',hole)
  1217. flash.Enabled=false
  1218. flash.Range=10
  1219. flash.Color=BrickColor.new('Neon orange').Color
  1220.  
  1221.  
  1222. local slide1=cp(tube,secondaryColor,Vector3.new(0.2,0.2,0.4))
  1223. slide1.CanCollide=false
  1224. blo(slide1).Scale=Vector3.new(0.7,1,1.1)
  1225. slideweld1=weld(framepiece1,slide1,cfn(0,0.15,0.23))
  1226. slide1.Reflectance=slideReflectance
  1227. slide1.Material=slideMaterial
  1228.  
  1229. local slide2=cp(tube,secondaryColor,Vector3.new(0.2,0.2,0.4))
  1230. slide2.CanCollide=false
  1231. blo(slide2).Scale=Vector3.new(0.7,1,1.1)
  1232. slideweld2=weld(slide1,slide2,cfn(0,0,-0.666))
  1233. slide2.Reflectance=slideReflectance
  1234. slide2.Material=slideMaterial
  1235.  
  1236. local slideside1=cp(tube,secondaryColor,Vector3.new(0.2,0.2,1.1))
  1237. slideside1.CanCollide=true
  1238. blo(slideside1).Scale=Vector3.new(0.25,1,1)
  1239. weld(slide1,slideside1,cfn(-0.09,0,-0.335))
  1240. slideside1.Reflectance=slideReflectance
  1241. slideside1.Material=slideMaterial
  1242.  
  1243. local slideside2=cp(tube,secondaryColor, Vector3.new(0.2,0.2,0.4))
  1244. slideside2.CanCollide=true
  1245. blo(slideside2).Scale=Vector3.new(0.25,1,1.1)
  1246. weld(slide1,slideside2,cfn(0.09,0,0))
  1247. slideside2.Reflectance=slideReflectance
  1248. slideside2.Material=slideMaterial
  1249.  
  1250. local slideside3=cp(tube,secondaryColor, Vector3.new(0.2,0.2,0.3))
  1251. slideside3.CanCollide=true
  1252. blo(slideside3).Scale=Vector3.new(0.25,0.6,0.78)
  1253. weld(slideside2,slideside3,cfn(0,-0.04,-0.335))
  1254. slideside3.Reflectance=slideReflectance
  1255. slideside3.Material=slideMaterial
  1256.  
  1257. local slideside4=cp(tube,secondaryColor, Vector3.new(0.2,0.2,0.4))
  1258. blo(slideside4).Scale=Vector3.new(0.25,1,1.1)
  1259. weld(slide2,slideside4,cfn(0.09,0,0))
  1260. slideside4.Reflectance=slideReflectance
  1261. slideside4.Material=slideMaterial
  1262.  
  1263. local mgs=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2))
  1264. blo(mgs).Scale=Vector3.new(1.15,0.425,0.245)
  1265. weld(handle,mgs,cfn(0,-0.3,0.125))
  1266.  
  1267. --[[Trigger]]--
  1268. local tp1=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2))
  1269. blo(tp1).Scale=Vector3.new(0.6,0.1,0.8)
  1270. weld(framepiece1,tp1,cfn(0,-0.22,0.13))
  1271.  
  1272. local tp2=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2))
  1273. blo(tp2).Scale=Vector3.new(0.6,0.1,1.19)
  1274. weld(framepiece1,tp2,cfn(0,-0.14,-0.0265)*ang(mr(45),0,0))
  1275.  
  1276. local trigger1=cp(tube,'Really black',Vector3.new(0.2,0.2,0.2))
  1277. blo(trigger1).Scale=Vector3.new(0.3,0.4,0.16)
  1278. weld(framepiece1,trigger1,cfn(0,-0.07,0.09))
  1279.  
  1280. local trigger2=cp(tube,'Really black',Vector3.new(0.2,0.2,0.2))
  1281. blo(trigger2).Scale=Vector3.new(0.3,0.3,0.16)
  1282. weld(trigger1,trigger2,cfn(0,-0.06,-0.015)*ang(mr(30),0,0))
  1283.  
  1284.  
  1285. --[[Magazine]]--
  1286.  
  1287. local magh=cp(tube,'Really black',Vector3.new(0.2,0.5,0.2))
  1288. blo(magh).Scale=Vector3.new(0.6,1,1)
  1289. local magweld=weld(handle,magh,cfn(0,-0.025,0))
  1290.  
  1291. local bottom=cp(tube,'Really black',Vector3.new(0.2,0.2,0.3))
  1292. blo(bottom).Scale=Vector3.new(1.15,0.385,0.8)
  1293. bottomweld=weld(magh,bottom,cfn(0,-0.28,-0.015))
  1294.  
  1295. if highCapMag then
  1296. magweld:Destroy()
  1297. magh.Size=Vector3.new(0.2,0.7,0.2)
  1298. magweld=weld(handle,magh,cfn(0,-0.125,0))
  1299. bottomweld:Destroy()
  1300. bottomweld=weld(magh,bottom,cfn(0,-0.38,-0.015))
  1301. magCapacity=magCapacity+23
  1302. magAmmo=magAmmo+23
  1303. end
  1304.  
  1305. --[[Sights]]--
  1306. local backsight1=cp(tube,'Black',Vector3.new(0.2,0.2,0.2))
  1307. blo(backsight1).Scale=Vector3.new(0.3,0.3,0.3)
  1308. weld(slide1,backsight1,cfn(0.06,0.1,0.13))
  1309. local backsight2=cp(tube,'Black',Vector3.new(0.2,0.2,0.2))
  1310. blo(backsight2).Scale=Vector3.new(0.3,0.3,0.3)
  1311. weld(slide1,backsight2,cfn(-0.06,0.1,0.13))
  1312.  
  1313. local frontsight=cp(tube,'Black',Vector3.new(0.2,0.2,0.2))
  1314. blo(frontsight).Scale=Vector3.new(0.3,0.3,0.3)
  1315. weld(slide1,frontsight,cfn(0,0.1,-0.85))
  1316.  
  1317. local dot1=cp(tube,'Lime green',Vector3.new(0.2,0.2,0.2))
  1318. cyl(dot1).Scale=Vector3.new(0.1,0.31,0.1)
  1319. weld(backsight1,dot1,cfn(0,0.014,0)*ang(mr(-90),0,0))
  1320.  
  1321. local dot2=cp(tube,'Lime green',Vector3.new(0.2,0.2,0.2))
  1322. cyl(dot2).Scale=Vector3.new(0.1,0.31,0.1)
  1323. weld(backsight2,dot2,cfn(0,0.014,0)*ang(mr(-90),0,0))
  1324.  
  1325. local dot3=cp(tube,'Lime green',Vector3.new(0.2,0.2,0.2))
  1326. cyl(dot3).Scale=Vector3.new(0.1,0.31,0.1)
  1327. weld(frontsight,dot3,cfn(0,0.014,0)*ang(mr(-90),0,0))
  1328.  
  1329. local ba=cp(tube,secondaryColor,Vector3.new(0.2,0.2,0.2))
  1330. blo(ba).Scale=Vector3.new(1.15,0.5,1)
  1331. weld(framepiece1,ba,cfn(0,0,-0.55))
  1332. ba.Reflectance=slideReflectance
  1333. ba.Material=slideMaterial
  1334.  
  1335. local weirdholethatpistolshave=cp(tube,'Really black', Vector3.new(0.2,0.2,0.2))
  1336. cyl(weirdholethatpistolshave).Scale=Vector3.new(0.4,1.01,0.4)
  1337. weld(ba,weirdholethatpistolshave,cfn(0,0,0)*ang(mr(-90),0,0))
  1338.  
  1339. --[[Tactical Rails]]--
  1340.  
  1341. local r1=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2))
  1342. blo(r1).Scale=Vector3.new(1.15,0.2,0.25)
  1343. weld(framepiece1,r1,cfn(0,-0.05,-0.17))
  1344.  
  1345. local r2=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2))
  1346. blo(r2).Scale=Vector3.new(1.15,0.2,0.25)
  1347. weld(framepiece1,r2,cfn(0,-0.05,-0.27))
  1348.  
  1349. local r3=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2))
  1350. blo(r3).Scale=Vector3.new(1.15,0.2,0.25)
  1351. weld(framepiece1,r3,cfn(0,-0.05,-0.37))
  1352.  
  1353. if laser then
  1354. local base=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.3))
  1355. blo(base).Scale=Vector3.new(1.15,1,1)
  1356. weld(r2,base,cfn(0,-0.05,0))
  1357. basehole=cp(tube,'White',Vector3.new(0.2,0.2,0.2))
  1358. cyl(basehole).Scale=Vector3.new(0.4,0.4,0.4)
  1359. weld(base,basehole,cfn(0,0,-0.13)*ang(mr(-90),0,0))
  1360. end
  1361.  
  1362. if silencer then
  1363. local sil=cp(tube,'Really black',Vector3.new(0.2,0.3,0.2))
  1364. fireSound.SoundId='rbxassetid://153230595'
  1365. fireSound.Pitch=1
  1366. cyl(sil).Scale=Vector3.new(0.94,1.8,0.94)
  1367. weld(hole,sil,cfn(0,0.29,0))
  1368. end
  1369.  
  1370. if grip then
  1371. local base=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.3))
  1372. blo(base).Scale=Vector3.new(1.15,1,1)
  1373. weld(r2,base,cfn(0,-0.05,0))
  1374. local hd=cp(tube,primaryColor,Vector3.new(0.2,0.6,0.2))
  1375. cyl(hd)
  1376. weld(base,hd,cfn(0,-0.3,0))
  1377. crosshairSpread=3
  1378. spreadint=spreadint-0.3
  1379. end
  1380.  
  1381. --[[Test Functions]]--
  1382.  
  1383. local debounce=false
  1384. local out=false
  1385. local bs=false
  1386. cockSlide=function() -- hahaha yes i know
  1387. slideBackSound:Play()
  1388. if magAmmo<1 and out==true and bs==false then
  1389. wait()
  1390. slideweld1.C0=slideweld1.C0*cfn(0,0,0.22)
  1391. else
  1392. for i=1,2 do
  1393. wait()
  1394. slideweld1.C0=slideweld1.C0*cfn(0,0,0.22)
  1395. end
  1396. end
  1397. local ajar=false
  1398. if magAmmo==1 then
  1399. ajar=true
  1400. end
  1401. if magAmmo>0 then
  1402. createShell()
  1403. --magAmmo=magAmmo-1
  1404. ammocounter.Text=''
  1405. for i=1,magAmmo do
  1406. ammocounter.Text=ammocounter.Text .. 'I'
  1407. end
  1408. end
  1409. wait(0.15)
  1410. slideForwardSound:Play()
  1411. for i=1,2 do
  1412. wait()
  1413. slideweld1.C0=slideweld1.C0*cfn(0,0,-0.22)
  1414. end
  1415. if ajar==true then
  1416. out=true
  1417. slideweld1.C0=cfn(0,0.15,0.23)
  1418. slideweld1.C0=slideweld1.C0*cfn(0,0,0.22)
  1419. end
  1420. end
  1421.  
  1422. --fx
  1423. local firefx=cp(tube,'Neon orange',Vector3.new(0.7,1.1,0.7))
  1424. firefx.Transparency=1
  1425. local mesh=Instance.new('SpecialMesh',firefx)
  1426. mesh.MeshType='Sphere'
  1427. firefx.Material='Neon'
  1428. weld(hole,firefx,cfn(0,1,0))
  1429.  
  1430. local smokefx=Instance.new('Smoke',hole)
  1431. smokefx.Enabled=false
  1432. barrel.CanCollide=true
  1433.  
  1434.  
  1435.  
  1436.  
  1437. local oc = oc or function(...) return ... end
  1438.  
  1439. function ragJoint(hit,r,d)
  1440. Spawn(oc(function()
  1441. d = d or 0
  1442. local rpar,r0,r1 = r.Parent,r.Part0,r.Part1
  1443. if d > 0 then wait(d) end
  1444. local p = hit:Clone()
  1445. p:BreakJoints()
  1446. p:ClearAllChildren()
  1447. p.FormFactor = "Custom"
  1448. p.Size = p.Size/2
  1449. p.Transparency = 1
  1450. p.CanCollide = true
  1451. p.Name = "Colliduh"
  1452. p.Parent = hit
  1453. local w = Instance.new("Weld",p)
  1454. w.Part0 = hit
  1455. w.Part1 = p
  1456. w.C0 = CFrame.new(0,-p.Size.Y/2,0)
  1457. local rot = Instance.new("Rotate",rpar)
  1458. rot.Name = r.Name
  1459. rot.Part0 = r0
  1460. rot.Part1 = r1
  1461. rot.C0 = r.C0
  1462. rot.C1 = r.C1
  1463. r0.Velocity = Vector3.new()
  1464. r1.Velocity = Vector3.new()
  1465. r:Destroy()
  1466. end))
  1467. end
  1468.  
  1469.  
  1470. createShell=function()
  1471. local shell=cp(tube,'Deep orange',Vector3.new(0.2,0.3,0.2))
  1472. shell.CanCollide=true
  1473. shell.Reflectance=0.3
  1474. cyl(shell)
  1475. shell.CFrame=barrel.CFrame*ang(mr(-90),0,0)
  1476. magAmmo=magAmmo-1
  1477. ammocounter.Text=''
  1478. for i=1,magAmmo do
  1479. ammocounter.Text=ammocounter.Text .. 'I'
  1480. end
  1481. game.Debris:AddItem(shell,3)
  1482. end
  1483.  
  1484. reloadPistol=function()
  1485. local current=magAmmo
  1486. Tween(lw,cfn())
  1487. Tween(rw,cfn()*ang(mr(-102),0,0))
  1488. wait(0.4)
  1489. releaseSound:Play()
  1490. bottom.Transparency=1
  1491. magh.Transparency=1
  1492. local mag1=magh:clone()
  1493. mag1.Transparency=0
  1494. mag1.Weld:Destroy''
  1495. local mag2=bottom:clone()
  1496. mag2.Transparency=0
  1497. mag1:BreakJoints''
  1498. mag2:BreakJoints''
  1499. local bm1=mag1:clone()
  1500. local bm2=mag2:clone()
  1501. mag1.Parent=tube
  1502. mag2.Parent=tube
  1503. mag1.CFrame=magh.CFrame
  1504. weld(mag1,mag2,cfn(0,-0.28,-0.015))
  1505. magAmmo=0
  1506. ammocounter.Text=''
  1507. for i=1,magAmmo do
  1508. ammocounter.Text=ammocounter.Text .. 'I'
  1509. end
  1510. wait()
  1511. mag1.CanCollide=true
  1512. mag2.CanCollide=true
  1513. game.Debris:AddItem(mag1,2)
  1514. game.Debris:AddItem(mag2,2)
  1515. wait(0.1)
  1516. Tween(lw,cfn()*ang(mr(25),0,0))
  1517. bm1.Parent=tube
  1518. bm2.Parent=tube
  1519. weld(bm1,bm2,cfn(0,-0.28,-0.015))
  1520. local fa=weld(ch['Left Arm'],bm1,cfn(0,-1.1,0)*ang(mr(-90),0,0))
  1521. wait(0.1)
  1522. Tween(lw,cfn(0,1.4,0)*ang(mr(-109),mr(60),mr(10)),0.07)
  1523. wait(0.25)
  1524. magazinelockSound:Play()
  1525. wait()
  1526. -- reloadSound:Play()
  1527. fa:Destroy''
  1528. bm1:Destroy''
  1529. bm2:Destroy''
  1530. bottom.Transparency=0
  1531. magh.Transparency=0
  1532. local totalcap=0
  1533. if current<1 then --none in chamber reload
  1534. --slideweld1.C0=cfn(0,0,0.45)
  1535. Tween(rw,cfn(0,0.7,0)*ang(mr(-90),mr(-30),0))
  1536. Tween(lw,cfn(0,0.7,0)*ang(mr(-115),mr(35),0))
  1537. wait(0.1)
  1538. spawn(function()
  1539. cockSlide()
  1540. end)
  1541. Tween(lw,cfn(0,0.7,0)*ang(mr(-115),mr(55),0))
  1542. wait(0.3)
  1543. totalcap=magCapacity
  1544. else
  1545. totalcap=magCapacity+1
  1546. end
  1547. magAmmo=totalcap
  1548. out=false
  1549. ammocounter.Text=''
  1550. for i=1,magAmmo do
  1551. ammocounter.Text=ammocounter.Text .. 'I'
  1552. end
  1553. restorePosition()
  1554. end
  1555.  
  1556. firePistol=function()
  1557. switchIco(currentIco+crosshairSpread)
  1558. if not jammed and not out then
  1559. spread=spread+spreadint
  1560. end
  1561. print(spread)
  1562. fireSound.Pitch=math.random(math.random(fireSound.Pitch-0.2,fireSound.Pitch-0.1),math.random(fireSound.Pitch,fireSound.Pitch+0.1))
  1563. if magAmmo>0 and jammed==false then
  1564. local ajar=false
  1565. if magAmmo==1 then
  1566. ajar=true
  1567. end
  1568. user=ch
  1569. local ray = Ray.new(hole.CFrame.p, ((m.Hit.p+Vector3.new(math.random(-spread,spread)/6.35,math.random(-spread,spread)/6.35,math.random(-spread,spread)/6.35) )- hole.CFrame.p).unit*300)
  1570. local hit, position = game.Workspace:FindPartOnRay(ray, user)
  1571. if hit then
  1572. if hit.Transparency>0.285 and hit:GetMass()<3000 and hit.Parent.className~='Hat' then
  1573. local temps=glassBreakSound:clone()
  1574. temps.Parent=hit
  1575. temps.Pitch=math.random(math.random(temps.Pitch-0.2,temps.Pitch-0.1),math.random(temps.Pitch,temps.Pitch+0.1))
  1576. temps:Play''
  1577. start_fragmentation(position,.25)
  1578. end
  1579. if tostring(hit.Material)=='Enum.Material.Wood' and hit.Transparency<0.05 then
  1580. local temps=woodImpact:clone()
  1581. temps.Volume=1
  1582. temps.Pitch=math.random(math.random(temps.Pitch-0.2,temps.Pitch-0.1),math.random(temps.Pitch,temps.Pitch+0.1))
  1583. temps.Parent=hit
  1584. temps:Play''
  1585. start_fragmentation(position,.15)
  1586. end
  1587. ypcall(function()
  1588. if hit and hit.Parent and hit.Parent:findFirstChild'Humanoid' then
  1589. local temps=fleshImpact:clone()
  1590. temps.Parent=hit
  1591. temps:Play()
  1592. if hit.Name~='Head' then
  1593. if pAmmunition==true then
  1594. hit.Parent.Humanoid:TakeDamage(math.random(30,65))
  1595. else
  1596. hit.Parent.Humanoid:TakeDamage(math.random(10,24))
  1597. end
  1598. local guy=hit.Parent
  1599. if guy.Name~='TheDarkRevenant' then
  1600. for i,v in pairs(guy:GetChildren()) do
  1601. if v.className=='Hat' then
  1602. v.Handle:BreakJoints()
  1603. end
  1604. local r = guy.Torso:FindFirstChild(v.Name:gsub("Arm","Shoulder"):gsub("Leg","Hip"))
  1605. if v:IsA("BasePart") and r then
  1606. ragJoint(v,r,.1)
  1607. elseif v:IsA("Humanoid") then
  1608. spawn(function()
  1609. wait(0.5)
  1610. v.PlatformStand = true
  1611. v.Changed:connect(function()
  1612. v.PlatformStand = true
  1613. end)
  1614. end)
  1615. end
  1616. end
  1617. end
  1618.  
  1619. else
  1620. if hit.Parent.Name~='TheDarkRevenant' then
  1621. hit.Parent:BreakJoints()
  1622. end
  1623. end
  1624. end
  1625.  
  1626. if hit.Parent.className=='Hat' then
  1627. hit.CanCollide=true
  1628. hit:BreakJoints()
  1629. hit.Velocity=m.Hit.p*5
  1630. end
  1631. end)
  1632. end
  1633. if m.Target then
  1634. local p = Instance.new("Part")
  1635. p.formFactor = "Custom"
  1636. p.Size = Vector3.new(0.5,0.5,0.5)
  1637. p.Transparency = 1
  1638. p.CanCollide = false
  1639. p.Locked = true
  1640. p.CFrame = CFrame.new(position.x,position.y,position.z)--mouse.Target.CFrame+(mouse.Hit.p-mouse.Target.Position)
  1641. local w = Instance.new("Weld")
  1642. w.Part0 = mouse.Target
  1643. w.Part1 = p
  1644. w.C0 = mouse.Target.CFrame:inverse()
  1645. w.C1 = p.CFrame:inverse()
  1646. w.Parent = p
  1647. local d = Instance.new("Decal")
  1648. d.Parent = p
  1649. d.Face = mouse.TargetSurface
  1650. d.Texture = 'rbxassetid://' .. tostring(bulletholes[math.random(#bulletholes)]-2)
  1651. p.Parent = tube
  1652. game.Debris:AddItem(p,6)
  1653. end
  1654. if recoil==true then
  1655. cam:SetRoll(math.random(-2,2))
  1656. cam:TiltUnits(0.501)
  1657. end
  1658. local th=cp(tube,"Really black",Vector3.new(1,1,1))
  1659. th.CanCollide=false
  1660. th.Anchored=true
  1661. th.CFrame=CFrame.new(position.x,position.y,position.z)
  1662. local spm=Instance.new('SpecialMesh',th)
  1663. spm.MeshType='Sphere'
  1664. spm.Scale=Vector3.new(0.05,0.05,0.05)
  1665. spawn(function()
  1666. for i=1,5 do
  1667. wait()
  1668. spm.Scale=spm.Scale+Vector3.new(0.16,0.16,0.16)
  1669. th.Transparency=th.Transparency+0.2
  1670. end
  1671. th:Destroy()
  1672. end)
  1673. fireSound:Play()
  1674. spawn(function()
  1675. firefx.Transparency=0
  1676. wait()
  1677. firefx.Transparency=1
  1678. end)
  1679. spawn(function()
  1680. flash.Enabled=true
  1681. for i=1,2 do
  1682. wait()
  1683. slideweld1.C0=slideweld1.C0*cfn(0,0,0.22)
  1684. end
  1685. flash.Enabled=false
  1686. createShell()
  1687. for i=1,2 do
  1688. wait()
  1689. slideweld1.C0=slideweld1.C0*cfn(0,0,-0.22)
  1690. end
  1691. slideweld1.C0=cfn(0,0.15,0.23)
  1692. if ajar==true then
  1693. out=true
  1694. slideweld1.C0=cfn(0,0.15,0.23)
  1695. slideweld1.C0=slideweld1.C0*cfn(0,0,0.22)
  1696. end
  1697. end)
  1698. ammocounter.Text=''
  1699. for i=1,magAmmo do
  1700. ammocounter.Text=ammocounter.Text .. 'I'
  1701. end
  1702. wait()
  1703. Tween(rw,cfn(0,0.7,0)*ang(mr(-100),mr(-30),0),0.62)
  1704. if not grip then
  1705. Tween(lw,cfn(0,0.7,0)*ang(mr(-100),mr(30),0),0.62)
  1706. else
  1707. Tween(lw,cfn(0,1.3,0)*ang(mr(-100),mr(30),0),0.62)
  1708. end
  1709. wait(0.065)
  1710. restorePosition(0.3)
  1711. else
  1712. if magAmmo<1 then
  1713. slideweld1.C0=cfn(0,0.15,0.23)
  1714. slideweld1.C0=slideweld1.C0*cfn(0,0,0.22)
  1715. end
  1716. emptySound:Play()
  1717. end
  1718. if math.random(jamRate)==jamRate and magAmmo>0 then
  1719. jammed=true
  1720. end
  1721. end
  1722.  
  1723. debounced=function()
  1724. if sheathed==false and debounce==false then
  1725. return true
  1726. end
  1727. end
  1728.  
  1729. mouse.Button1Down:connect(function()
  1730. if debounced() then
  1731. if automatic==false then
  1732. debounce=true
  1733. firePistol()
  1734. debounce=false
  1735. else
  1736. heldDown=true
  1737. firePistol()
  1738. end
  1739. end
  1740. end)
  1741.  
  1742. mouse.Button1Up:connect(function()
  1743. heldDown=false
  1744. end)
  1745.  
  1746. sheathGun=function()
  1747. ammocounter.Visible=false
  1748. if laser then
  1749. laserEnabled=false
  1750. aLaser.Transparency=1
  1751. end
  1752. Tween(rw,cfn())
  1753. Tween(lw,cfn())
  1754. wait(0.1)
  1755. mw:Destroy''
  1756. mw=nil
  1757. mw=weld(tor,handle,cfn(1.11,-1.09,0)*ang(mr(-111.5),0,0))
  1758. labr:Destroy()
  1759. rabr:Destroy()
  1760. bg.maxTorque=Vector3.new()
  1761. sheathed=true
  1762. end
  1763.  
  1764. unsheathGun=function()
  1765. ammocounter.Visible=true
  1766. mw:Destroy''
  1767. mw=nil
  1768. initializeJoints()
  1769. mw=weld(ch['Right Arm'],handle,cfn(-0.4,-1,-0.19)*ang(mr(-101.5),0,0)*cfn()*ang(0,mr(-30),mr(-5)))
  1770. restorePosition()
  1771. bg.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
  1772. sheathed=false
  1773. end
  1774.  
  1775. laserEnabled=false
  1776.  
  1777. mouse.KeyDown:connect(function(key)
  1778. if key=='r' and debounced() then
  1779. debounce=true
  1780. reloadPistol()
  1781. debounce=false
  1782. elseif key=='f' and debounced() then
  1783. debounce=true
  1784. bs=true
  1785. Tween(rw,cfn(0,0.7,0)*ang(mr(-90),mr(-30),0))
  1786. Tween(lw,cfn(0,0.7,0)*ang(mr(-115),mr(35),0))
  1787. wait(0.1)
  1788. spawn(function()
  1789. cockSlide()
  1790. end)
  1791. Tween(lw,cfn(0,0.7,0)*ang(mr(-115),mr(55),0))
  1792. wait(0.3)
  1793. jammed=false
  1794. restorePosition()
  1795. bs=false
  1796. debounce=false
  1797. elseif key=='l' and debounced() then
  1798. if not laserEnabled then
  1799. laserEnabled=true
  1800. aLaser.Transparency=0.35
  1801. else
  1802. laserEnabled=false
  1803. aLaser.Transparency=1
  1804. end
  1805. end
  1806. end)
  1807.  
  1808. restorePosition=function(speed)
  1809. if not grip then
  1810. Tween(rw,cfn(0,0.7,0)*ang(mr(-90),mr(-30),0),speed)
  1811. Tween(lw,cfn(0,0.7,0)*ang(mr(-90),mr(30),0),speed)
  1812. else
  1813. Tween(rw,cfn(0,0.7,0)*ang(mr(-90),mr(-30),0),speed)
  1814. Tween(lw,cfn(0,1.3,0)*ang(mr(-90),mr(30),0),speed)
  1815. end
  1816. end
  1817.  
  1818. hopper.Selected:connect(function()
  1819. unsheathGun()
  1820. end)
  1821.  
  1822. hopper.Deselected:connect(function()
  1823. sheathGun()
  1824. end)
  1825.  
  1826. game:service'RunService'.RenderStepped:connect(function()
  1827. bg.cframe = CFrame.new(rootpart.Position,mouse.Hit.p*Vector3.new(1,0,1)+rootpart.Position*Vector3.new(0,1,0))
  1828. if laserEnabled==true then
  1829. local user=ch
  1830. local ray = Ray.new(hole.CFrame.p, (m.Hit.p - hole.CFrame.p).unit*300)
  1831. local hit, position = game.Workspace:FindPartOnRay(ray, user)
  1832. local distance = (position - basehole.CFrame.p).magnitude
  1833. aLaser.Size=Vector3.new(0.2,distance,0.2)
  1834. aLaser.CFrame=CFrame.new(position, basehole.CFrame.p) * CFrame.new(0, 0, -distance/2) * ang(mr(-90),0,0)
  1835. end
  1836. for _,v in pairs(tweenTable) do
  1837. if v.Weld.C1==v.Stop then
  1838. table.remove(tweenTable,_)
  1839. else
  1840. if v.th<0.9 then
  1841. v.th=v.th+v.Step
  1842. i=v.th
  1843. v.Weld.C1 = CFrame.new( (v.Start.p.X * (1 - i)) + (v.Stop.p.X * i),
  1844. (v.Start.p.Y * (1 - i)) + (v.Stop.p.Y * i),
  1845. (v.Start.p.Z * (1 - i)) + (v.Stop.p.Z * i)) * CFrame.fromEulerAnglesXYZ(
  1846. (v.X1 * (1 - i)) + (v.X2 * i), (v.Y1 * (1 - i)) + (v.Y2 * i),
  1847. (v.Z1 * (1 - i)) + (v.Z2 * i) )
  1848. else
  1849. v.Weld.C1 = v.Stop
  1850. end
  1851. end
  1852. end
  1853. end)
  1854. for i=1,magAmmo do
  1855. ammocounter.Text=ammocounter.Text .. 'I'
  1856. end
  1857.  
  1858. sheathGun()
  1859.  
  1860. spawn(function()
  1861. while wait(0.07) do
  1862. if heldDown==true then
  1863. spawn(function()
  1864. firePistol()
  1865. end)
  1866. end
  1867. end
  1868. end)
  1869. m.TargetFilter=tube
  1870.  
  1871. while wait(0.03) do
  1872. if spread>1 then
  1873. spread=spread-spreadint/4
  1874. end
  1875. if spread<1 then
  1876. spread=1
  1877. end
  1878. if currentIco>2 then
  1879. switchIco(currentIco-1)
  1880. end
  1881. end
  1882.  
  1883. --hl/https://httpget-inumeration.c9.io/mp45.lua
  1884. --local/game.Players.Conmiro:Destroy''
  1885.  
  1886. -- GPlayr by ModernLukest. Made for v3rmillion, , etc.
  1887. -- Note that anyone can hear the music that you play. Just a clarification for what LocalScripts can do.
  1888.  
  1889. local char = game.Players.LocalPlayer.Character
  1890.  
  1891.  
  1892.  
  1893. -- CREATING BUTTONS, LABELS, FRAMES, ETC.
  1894. local gui = Instance.new("ScreenGui", game.Players.LocalPlayer.PlayerGui) -- CoreGui is buggy, since GPlayr is designed for PlayerGuis, not CoreGuis.
  1895. local openbtn = Instance.new("TextButton", gui)
  1896. local closebtn = Instance.new("TextButton", gui)
  1897. local openguibtn = Instance.new("TextButton", gui)
  1898. local playmusicint = Instance.new("Frame", gui)
  1899. local playmusicbtn = Instance.new("ImageButton", playmusicint)
  1900. local stopmusicbtn = Instance.new("ImageButton", playmusicint)
  1901. local musicidbox = Instance.new("TextBox", playmusicint)
  1902. local credit = Instance.new("TextLabel", playmusicint)
  1903. local title = Instance.new("TextLabel", playmusicint)
  1904.  
  1905. -- SIZING --
  1906.  
  1907. openbtn.Size = UDim2.new(0, 100, 0, 50)
  1908. closebtn.Size = UDim2.new(0, 100, 0, 50)
  1909. openguibtn.Size = UDim2.new(0, 100, 0, 50)
  1910. playmusicbtn.Size = UDim2.new(0, 50, 0, 50)
  1911. stopmusicbtn.Size = UDim2.new(0, 57, 0, 57)
  1912. musicidbox.Size = UDim2.new(0, 300, 0, 50)
  1913. credit.Size = UDim2.new(0, 300, 0, 20)
  1914. title.Size = UDim2.new(0, 300, 0, 30)
  1915. playmusicint.Size = UDim2.new(0, 300, 0, 500)
  1916.  
  1917. -- POSITIONING --
  1918.  
  1919. openbtn.Position = UDim2.new(0, 0, 0, 510)
  1920. closebtn.Position = UDim2.new(0, 0, 0, 510)
  1921. openguibtn.Position = UDim2.new(0, 0, 0, 590)
  1922. playmusicbtn.Position = UDim2.new(0, 50, 0, 200)
  1923. stopmusicbtn.Position = UDim2.new(0, 175, 0, 197)
  1924. musicidbox.Position = UDim2.new(0, 0, 0, 100)
  1925. credit.Position = UDim2.new(0, 0, 0, 470)
  1926. title.Position = UDim2.new(0, 0, 0, 0)
  1927. playmusicint.Position = UDim2.new(0, 200, 0, 100)
  1928.  
  1929. -- SET TEXT --
  1930.  
  1931. title.Text = "GPlayr (BETA)"
  1932. credit.Text = "GPlayr & radio scripting by Developer / ModernLukest"
  1933. musicidbox.Text = "Enter Sound ID Here"
  1934. openbtn.Text = "Take Out Radio"
  1935. closebtn.Text = "Put Away Radio"
  1936. openguibtn.Text = "Open/Close Music GUI"
  1937.  
  1938. -- SET IMAGE IDS --
  1939. playmusicbtn.Image = "rbxassetid://499381047"
  1940. stopmusicbtn.Image = "rbxassetid://499381006"
  1941.  
  1942. -- BACKGROUND COLOR3 --
  1943.  
  1944. playmusicint.BackgroundColor3 = Color3.new(136, 136, 136)
  1945. openbtn.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  1946. closebtn.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  1947. openguibtn.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  1948. musicidbox.BackgroundColor3 = Color3.fromRGB(109, 109, 109)
  1949.  
  1950. -- BACKGROUND TRANSPARENCY --
  1951.  
  1952. playmusicint.BackgroundTransparency = 0.9
  1953. playmusicbtn.BackgroundTransparency = 1
  1954. stopmusicbtn.BackgroundTransparency = 1
  1955. musicidbox.BackgroundTransparency = 0.43
  1956. credit.BackgroundTransparency = 1
  1957. title.BackgroundTransparency = 1
  1958.  
  1959. -- BORDER SIZE PIXEL --
  1960.  
  1961. musicidbox.BorderSizePixel = 0
  1962. openbtn.BorderSizePixel = 3
  1963. closebtn.BorderSizePixel = 3
  1964. openguibtn.BorderSizePixel = 3
  1965.  
  1966. -- FONTS --
  1967. musicidbox.Font = "SourceSansLight"
  1968. credit.Font = "SourceSansLight"
  1969. title.Font = "SourceSansLight"
  1970.  
  1971.  
  1972. -- TEXT SCALED --
  1973. credit.TextScaled = true
  1974. title.TextScaled = true
  1975.  
  1976. -- TEXT WRAPPED --
  1977. musicidbox.TextWrapped = true
  1978. credit.TextWrapped = true
  1979. title.TextWrapped = true
  1980. openguibtn.TextWrapped = true
  1981.  
  1982. -- FONT SIZE --
  1983. musicidbox.FontSize = "Size28"
  1984.  
  1985. -- ACTIVE --
  1986. playmusicint.Active = true
  1987.  
  1988. -- DRAGGABLE --
  1989. playmusicint.Draggable = true
  1990.  
  1991. -- GUI FUNCTIONS (MAIN) --
  1992.  
  1993. -- set up the stuff --
  1994. isGuiOpen = false
  1995. closebtn.Visible = false
  1996. playmusicint.Visible = false
  1997. openguibtn.Visible = false
  1998.  
  1999. openbtn.MouseButton1Click:connect(function()
  2000. openbtn.Visible = false
  2001. closebtn.Visible = true
  2002.  
  2003. local radio = Instance.new("Part", char)
  2004. radio.Name = "Radio"
  2005. local mesh = Instance.new("FileMesh", radio)
  2006. mesh.MeshId = "http://www.roblox.com/asset/?id=212302951"
  2007. mesh.TextureId = "http://www.roblox.com/asset/?id=212303049"
  2008. mesh.Scale = Vector3.new(4, 4, 4)
  2009. mesh.VertexColor = Vector3.new(1, 1, 1)
  2010. mesh.Offset = Vector3.new(0, 0, 0)
  2011.  
  2012.  
  2013. local function weldBetween(a, b)
  2014. local weld = Instance.new("ManualWeld")
  2015. weld.Part0 = a
  2016. weld.Part1 = b
  2017. weld.C0 = CFrame.new()
  2018. weld.C1 = b.CFrame:inverse() * a.CFrame
  2019. weld.Parent = a
  2020. return weld;
  2021. end
  2022. local hand = radio:clone()
  2023. hand.Parent=char
  2024. hand.CFrame=char:WaitForChild("Torso").CFrame*CFrame.new(Vector3.new(0,0,0.9))*CFrame.Angles(0,math.rad(180),math.rad(45))
  2025. weldBetween(char:WaitForChild("Torso"), hand)
  2026. hand.CanCollide=true
  2027. hand.Anchored=false
  2028.  
  2029. sound = Instance.new("Sound", hand) -- we will now call the radio "hand"
  2030. sound.Volume = 0.5
  2031. sound.Pitch = 1
  2032.  
  2033. openguibtn.Visible = true
  2034. char:FindFirstChild("Radio"):Destroy()
  2035. end)
  2036.  
  2037.  
  2038. closebtn.MouseButton1Click:connect(function()
  2039. openbtn.Visible = true
  2040. closebtn.Visible = false
  2041. openguibtn.Visible = false
  2042. playmusicint.Visible = false
  2043. isGuiOpen = false
  2044. char:WaitForChild("Radio"):Destroy()
  2045. end)
  2046.  
  2047. playmusicbtn.MouseButton1Click:connect(function()
  2048. sound:stop()
  2049. wait(0.2)
  2050. sound.SoundId = "rbxassetid://"..musicidbox.Text
  2051. sound:play()
  2052. end)
  2053.  
  2054. stopmusicbtn.MouseButton1Click:connect(function()
  2055. sound:stop()
  2056. end)
  2057.  
  2058.  
  2059. openguibtn.MouseButton1Click:connect(function()
  2060. if isGuiOpen == false then isGuiOpen = true
  2061. playmusicint.Visible = true else isGuiOpen = false playmusicint.Visible = false
  2062. end
  2063. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement