hawoody

RPG

Apr 15th, 2018
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.59 KB | None | 0 0
  1. --Converted with ttyyuu12345's model to script plugin v4
  2. function sandbox(var,func)
  3. local env = getfenv(func)
  4. local newenv = setmetatable({},{
  5. __index = function(self,k)
  6. if k=="script" then
  7. return var
  8. else
  9. return env[k]
  10. end
  11. end,
  12. })
  13. setfenv(func,newenv)
  14. return func
  15. end
  16. cors = {}
  17. mas = Instance.new("Model",game:GetService("Lighting"))
  18. Tool0 = Instance.new("Tool")
  19. Part1 = Instance.new("Part")
  20. SpecialMesh2 = Instance.new("SpecialMesh")
  21. Sound3 = Instance.new("Sound")
  22. Sound4 = Instance.new("Sound")
  23. LocalScript5 = Instance.new("LocalScript")
  24. Script6 = Instance.new("Script")
  25. Sound7 = Instance.new("Sound")
  26. Sound8 = Instance.new("Sound")
  27. Script9 = Instance.new("Script")
  28. LocalScript10 = Instance.new("LocalScript")
  29. Animation11 = Instance.new("Animation")
  30. LocalScript12 = Instance.new("LocalScript")
  31. Part13 = Instance.new("Part")
  32. SpecialMesh14 = Instance.new("SpecialMesh")
  33. Script15 = Instance.new("Script")
  34. Script16 = Instance.new("Script")
  35. LocalScript17 = Instance.new("LocalScript")
  36. Tool0.Name = "RPG-7"
  37. Tool0.Parent = mas
  38. Tool0.GripPos = Vector3.new(0.0500000007, -0.600000024, -1)
  39. Tool0.ToolTip = "RPG-7"
  40. Tool0.CanBeDropped = false
  41. Part1.Name = "Handle"
  42. Part1.Parent = Tool0
  43. Part1.Transparency = 1
  44. Part1.Rotation = Vector3.new(92.1199951, 62, -91.8699951)
  45. Part1.FormFactor = Enum.FormFactor.Custom
  46. Part1.Size = Vector3.new(0.839999974, 1.14999998, 3.55000019)
  47. Part1.CFrame = CFrame.new(-70.7470474, 13.1006594, 24.1488132, -0.0153169353, 0.469224393, 0.882945836, 0.00813866127, 0.883078873, -0.469153851, -0.999849558, 0, -0.0173449218)
  48. Part1.BottomSurface = Enum.SurfaceType.Smooth
  49. Part1.TopSurface = Enum.SurfaceType.Smooth
  50. Part1.Position = Vector3.new(-70.7470474, 13.1006594, 24.1488132)
  51. Part1.Orientation = Vector3.new(27.9799995, 91.1299973, 0.529999971)
  52. SpecialMesh2.Parent = Part1
  53. SpecialMesh2.MeshId = "http://www.roblox.com/asset/?id=94690054"
  54. SpecialMesh2.TextureId = "http://www.roblox.com/asset/?id=94689966"
  55. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  56. Sound3.Name = "ReloadSound"
  57. Sound3.Parent = Part1
  58. Sound3.Pitch = 1.1000000238419
  59. Sound3.SoundId = "http://www.roblox.com/Asset?ID=132456167"
  60. Sound3.Volume = 1
  61. Sound4.Name = "FireSound"
  62. Sound4.Parent = Part1
  63. Sound4.SoundId = "http://www.roblox.com/Asset?ID=132456187"
  64. Sound4.Volume = 1
  65. LocalScript5.Name = "MouseIcon"
  66. LocalScript5.Parent = Tool0
  67. table.insert(cors,sandbox(LocalScript5,function()
  68. local MOUSE_ICON = 'rbxasset://textures/GunCursor.png'
  69. local RELOADING_ICON = 'rbxasset://textures/GunWaitCursor.png'
  70.  
  71. local Tool = script.Parent
  72.  
  73. local Mouse = nil
  74.  
  75. local function UpdateIcon()
  76. Mouse.Icon = Tool.Enabled and MOUSE_ICON or RELOADING_ICON
  77. end
  78.  
  79. local function OnEquipped(mouse)
  80. Mouse = mouse
  81. UpdateIcon()
  82. end
  83.  
  84. local function OnChanged(property)
  85. if property == 'Enabled' then
  86. UpdateIcon()
  87. end
  88. end
  89.  
  90. Tool.Equipped:connect(OnEquipped)
  91. Tool.Changed:connect(OnChanged)
  92.  
  93. end))
  94. Script6.Name = "Launcher"
  95. Script6.Parent = Tool0
  96. table.insert(cors,sandbox(Script6,function()
  97. -----------------
  98. --| Constants |--
  99. -----------------
  100.  
  101. local COOLDOWN = 4 -- Seconds until tool can be used again
  102.  
  103. -- RocketPropulsion Fields
  104. local TARGET_RADIUS = 5
  105. local MAX_SPEED = 95
  106. local MAX_TORQUE = Vector3.new(4e6, 4e6, 0)
  107. local MAX_THRUST = 50000
  108. local THRUST_P = 500
  109. local THRUST_D = 50000
  110.  
  111. local TARGET_OVERSHOOT_DISTANCE = 10000000
  112.  
  113. local ROCKET_MESH_ID = 'http://www.roblox.com/asset/?id=94690081'
  114. local ROCKET_MESH_SCALE = Vector3.new(2.5, 2.5, 2)
  115. local ROCKET_PART_SIZE = Vector3.new(1, 1, 4)
  116.  
  117. --------------------
  118. --| WaitForChild |--
  119. --------------------
  120.  
  121. -- Waits for parent.child to exist, then returns it
  122. local function WaitForChild(parent, childName)
  123. assert(parent, "ERROR: WaitForChild: parent is nil")
  124. while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
  125. return parent[childName]
  126. end
  127.  
  128. -----------------
  129. --| Variables |--
  130. -----------------
  131.  
  132. local DebrisService = Game:GetService('Debris')
  133. local PlayersService = Game:GetService('Players')
  134.  
  135. local Tool = script.Parent
  136. local ToolHandle = Tool.Handle
  137.  
  138. local RocketScript = WaitForChild(script, 'Rocket')
  139.  
  140. local SwooshSound = WaitForChild(script, 'Swoosh')
  141. local BoomSound = WaitForChild(script, 'Boom')
  142. local ReloadSound = WaitForChild(ToolHandle, 'ReloadSound')
  143. local FireSound = WaitForChild(ToolHandle, 'FireSound')
  144.  
  145. local MyModel = nil
  146. local MyPlayer = nil
  147.  
  148. local BaseRocket = nil
  149. local RocketClone = nil
  150.  
  151. -----------------
  152. --| Functions |--
  153. -----------------
  154.  
  155. local function MakeBaseRocket()
  156. -- Set up the rocket part
  157. local rocket = Instance.new('Part')
  158. rocket.Name = 'Rocket'
  159. rocket.FormFactor = Enum.FormFactor.Custom --NOTE: This must be done before changing Size
  160. rocket.Size = ROCKET_PART_SIZE
  161. rocket.CanCollide = false
  162. rocket.BottomSurface = Enum.SurfaceType.Smooth
  163. rocket.TopSurface = Enum.SurfaceType.Smooth
  164.  
  165. -- Add the mesh
  166. local mesh = Instance.new('SpecialMesh', rocket)
  167. mesh.MeshId = ROCKET_MESH_ID
  168. mesh.Scale = ROCKET_MESH_SCALE
  169. mesh.TextureId = ToolHandle.Mesh.TextureId
  170.  
  171. -- Add fire
  172. local fire = Instance.new('Fire', rocket)
  173. fire.Heat = 3
  174. fire.Size = 2
  175.  
  176. -- Add the propulsion
  177. local rocketPropulsion = Instance.new('RocketPropulsion', rocket)
  178. rocketPropulsion.CartoonFactor = 1
  179. rocketPropulsion.TargetRadius = TARGET_RADIUS
  180. rocketPropulsion.MaxSpeed = MAX_SPEED
  181. rocketPropulsion.MaxTorque = MAX_TORQUE
  182. rocketPropulsion.MaxThrust = MAX_THRUST
  183. rocketPropulsion.ThrustP = THRUST_P
  184. rocketPropulsion.ThrustD = THRUST_D
  185.  
  186. -- Clone the sounds
  187. local swooshSoundClone = SwooshSound:Clone()
  188. swooshSoundClone.Parent = rocket
  189. local boomSoundClone = BoomSound:Clone()
  190. boomSoundClone.Parent = rocket
  191.  
  192. -- Attach creator tags
  193. local creatorTag = Instance.new('ObjectValue', rocket)
  194. creatorTag.Name = 'creator' --NOTE: Must be called 'creator' for website stats
  195. creatorTag.Value = MyPlayer
  196. local iconTag = Instance.new('StringValue', creatorTag)
  197. iconTag.Name = 'icon'
  198. iconTag.Value = Tool.TextureId
  199.  
  200. -- Finally, clone the rocket script and enable it
  201. local rocketScriptClone = RocketScript:Clone()
  202. rocketScriptClone.Parent = rocket
  203. rocketScriptClone.Disabled = false
  204.  
  205. return rocket
  206. end
  207.  
  208. local function OnEquipped()
  209. MyModel = Tool.Parent
  210. MyPlayer = PlayersService:GetPlayerFromCharacter(MyModel)
  211. BaseRocket = MakeBaseRocket()
  212. RocketClone = BaseRocket:Clone()
  213. end
  214.  
  215. local function OnActivated(byFireButton)
  216. if Tool.Enabled and MyModel and MyModel:FindFirstChild('Humanoid') and MyModel.Humanoid.Health > 0 then
  217. Tool.Enabled = false
  218.  
  219. -- Get the target position
  220. local targetPosition = MyModel.Humanoid.TargetPoint
  221. if byFireButton then -- Using Fire Button, shoot forwards
  222. targetPosition = MyModel.Humanoid.Torso.CFrame.lookVector * 1000
  223. end
  224.  
  225. -- Position the rocket clone
  226. local spawnPosition = ToolHandle.Position + (ToolHandle.CFrame.lookVector * (ToolHandle.Size.z / 2))
  227. RocketClone.CFrame = CFrame.new(spawnPosition, targetPosition) --NOTE: This must be done before assigning Parent
  228. DebrisService:AddItem(RocketClone, 30)
  229. RocketClone.Parent = Workspace
  230.  
  231. -- Assign target and launch!
  232. FireSound:Play()
  233. local rocketPropulsion = RocketClone:FindFirstChild('RocketPropulsion')
  234. if rocketPropulsion then
  235. local direction = (targetPosition - RocketClone.Position).unit
  236. rocketPropulsion.TargetOffset = RocketClone.Position + (direction * TARGET_OVERSHOOT_DISTANCE)
  237. rocketPropulsion:Fire()
  238. end
  239.  
  240. wait(0) --TODO: Remove when sounds realize they can be played as soon as they enter the Workspace
  241.  
  242. -- Swoosh!
  243. local swooshSound = RocketClone:FindFirstChild('Swoosh')
  244. if swooshSound then
  245. swooshSound:Play()
  246. end
  247.  
  248. -- Prepare the next rocket to be fired
  249. RocketClone = BaseRocket:Clone()
  250.  
  251. ReloadSound:Play()
  252.  
  253. wait(COOLDOWN)
  254.  
  255. -- Stop the reloading sound if it hasn't already finished
  256. ReloadSound:Stop()
  257.  
  258. Tool.Enabled = true
  259. end
  260. end
  261.  
  262. local function OnUnequipped()
  263. ReloadSound:Stop() --TODO: This does not work online
  264. end
  265.  
  266. -- Also activate when the Fire Button is down
  267. local function OnChildAdded(child)
  268. if child.Name == 'FireButtonDown' then
  269. child.Changed:connect(function(newValue)
  270. if newValue == true then
  271. OnActivated(true)
  272. end
  273. end)
  274. end
  275. end
  276.  
  277. --------------------
  278. --| Script Logic |--
  279. --------------------
  280.  
  281. Tool.Equipped:connect(OnEquipped)
  282. Tool.Activated:connect(OnActivated)
  283. Tool.Unequipped:connect(OnUnequipped)
  284. Tool.ChildAdded:connect(OnChildAdded) --NOTE: Added for Fire Button
  285.  
  286. end))
  287. Sound7.Name = "Boom"
  288. Sound7.Parent = Script6
  289. Sound7.SoundId = "http://www.roblox.com/Asset?ID=133680244"
  290. Sound7.Volume = 1
  291. Sound8.Name = "Swoosh"
  292. Sound8.Parent = Script6
  293. Sound8.Pitch = 1.2999999523163
  294. Sound8.SoundId = "rbxasset://sounds/Rocket whoosh 01.wav"
  295. Sound8.Volume = 0.69999998807907
  296. Sound8.Looped = true
  297. Script9.Name = "Rocket"
  298. Script9.Parent = Script6
  299. Script9.Disabled = true
  300. table.insert(cors,sandbox(Script9,function()
  301. -----------------
  302. --| Constants |--
  303. -----------------
  304.  
  305. local BLAST_RADIUS = 6
  306. local BLAST_PRESSURE = 750000
  307.  
  308. -- Rocket will fly through things named these
  309. local ROCKET_IGNORE_LIST = {rocket = 1, handle = 1, effect = 1, water = 1} --NOTE: Keys must be lowercase, values must evaluate to true
  310.  
  311. --------------------
  312. --| WaitForChild |--
  313. --------------------
  314.  
  315. -- Waits for parent.child to exist, then returns it
  316. local function WaitForChild(parent, childName)
  317. assert(parent, "ERROR: WaitForChild: parent is nil")
  318. while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
  319. return parent[childName]
  320. end
  321.  
  322. -----------------
  323. --| Variables |--
  324. -----------------
  325.  
  326. local DebrisService = Game:GetService('Debris')
  327.  
  328. local Rocket = script.Parent
  329. local CreatorTag = WaitForChild(Rocket, 'creator')
  330.  
  331. local Connection = nil
  332.  
  333. -----------------
  334. --| Functions |--
  335. -----------------
  336.  
  337. -- Returns the ancestor that contains a Humanoid, if it exists
  338. local function FindCharacterAncestor(subject)
  339. if subject and subject ~= Workspace then
  340. local humanoid = subject:FindFirstChild('Humanoid')
  341. if humanoid then
  342. return subject, humanoid
  343. else
  344. return FindCharacterAncestor(subject.Parent)
  345. end
  346. end
  347. return nil
  348. end
  349.  
  350. local function OnExplosionHit(hitPart)
  351. if hitPart then
  352. local _, humanoid = FindCharacterAncestor(hitPart.Parent)
  353. if humanoid and humanoid.Health > 0 then
  354. local hitBindable = humanoid:FindFirstChild('Hit')
  355. if hitBindable then
  356. hitBindable:Invoke(0, CreatorTag)
  357. else
  358. print("Could not find BindableFunction 'Hit'")
  359. end
  360. end
  361. end
  362. end
  363.  
  364. local function OnTouched(otherPart)
  365. if Rocket and otherPart then
  366. -- Fly through anything in the ignore list
  367. if ROCKET_IGNORE_LIST[string.lower(otherPart.Name)] then
  368. return
  369. end
  370.  
  371. -- Fly through the creator
  372. local myPlayer = CreatorTag.Value
  373. if myPlayer and myPlayer.Character and myPlayer.Character:IsAncestorOf(otherPart) then
  374. return
  375. end
  376.  
  377. -- Create the explosion
  378. local explosion = Instance.new('Explosion')
  379. explosion.BlastPressure = BLAST_PRESSURE
  380. explosion.BlastRadius = BLAST_RADIUS
  381. explosion.Position = Rocket.Position
  382. explosion.Hit:connect(OnExplosionHit)
  383. explosion.Parent = Workspace
  384.  
  385. -- Start playing the boom sound
  386. local boomSound = Rocket:FindFirstChild('Boom')
  387. if boomSound then
  388. boomSound:Play()
  389. end
  390.  
  391. -- NOTE:
  392. -- If we just destroyed the rocket at this point, the boom sound would be destroyed too,
  393. -- so instead we will hide the rocket, keep it in the same spot, and schedule it for deletion
  394.  
  395. -- Stop playing the swoosh sound
  396. local swooshSound = Rocket:FindFirstChild('Swoosh')
  397. if swooshSound then
  398. swooshSound:Stop()
  399. end
  400.  
  401. -- Put out the fire
  402. local fire = Rocket:FindFirstChild('Fire')
  403. if fire then
  404. fire:Destroy()
  405. end
  406.  
  407. Rocket.Transparency = 1
  408. Rocket.CanCollide = false
  409. Rocket.Anchored = true
  410. DebrisService:AddItem(Rocket, 3)
  411.  
  412. -- Destroy the connection so this method won't be called again
  413. Connection:disconnect()
  414. end
  415. end
  416.  
  417. --------------------
  418. --| Script Logic |--
  419. --------------------
  420.  
  421. -- Arm the rocket and save the touch connection so we can disconnect it later
  422. Connection = Rocket.Touched:connect(OnTouched)
  423.  
  424. end))
  425. LocalScript10.Name = "Animation"
  426. LocalScript10.Parent = Tool0
  427. table.insert(cors,sandbox(LocalScript10,function()
  428. --------------------
  429. --| WaitForChild |--
  430. --------------------
  431.  
  432. -- Waits for parent.child to exist, then returns it
  433. local function WaitForChild(parent, childName)
  434. assert(parent, "ERROR: WaitForChild: parent is nil")
  435. while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
  436. return parent[childName]
  437. end
  438.  
  439. -----------------
  440. --| Variables |--
  441. -----------------
  442.  
  443. local Tool = script.Parent
  444.  
  445. local FireAndReloadAnimation = WaitForChild(script, 'FireAndReload')
  446.  
  447. local FireAndReloadTrack = nil
  448.  
  449. -----------------
  450. --| Functions |--
  451. -----------------
  452.  
  453. local function OnEquipped()
  454. local myModel = Tool.Parent
  455. local humanoid = myModel:FindFirstChild('Humanoid')
  456. if humanoid then -- Preload animations
  457. FireAndReloadTrack = humanoid:LoadAnimation(FireAndReloadAnimation)
  458. end
  459. end
  460.  
  461. local function OnChanged(property)
  462. if property == 'Enabled' and Tool.Enabled == false then
  463. -- Play fire and reload animation
  464. if FireAndReloadTrack then
  465. FireAndReloadTrack:Play()
  466. end
  467. end
  468. end
  469.  
  470. local function OnUnequipped()
  471. -- Stop animations
  472. if FireAndReloadTrack then FireAndReloadTrack:Stop() end
  473. end
  474.  
  475. --------------------
  476. --| Script Logic |--
  477. --------------------
  478.  
  479. Tool.Equipped:connect(OnEquipped)
  480. Tool.Changed:connect(OnChanged)
  481. Tool.Unequipped:connect(OnUnequipped)
  482.  
  483. end))
  484. Animation11.Name = "FireAndReload"
  485. Animation11.Parent = LocalScript10
  486. Animation11.AnimationId = "http://www.roblox.com/Asset?ID=94771598"
  487. LocalScript12.Name = "VisualizeReload"
  488. LocalScript12.Parent = Tool0
  489. table.insert(cors,sandbox(LocalScript12,function()
  490. -----------------
  491. --| Constants |--
  492. -----------------
  493.  
  494. local ROCKET_MESH_ID = ''
  495. local ROCKET_MESH_SCALE = Vector3.new(1, 1, 1)
  496.  
  497. local ANIM_TOTAL_TIME = 3.4 -- Total length of FireAndReload animation
  498. local ROCKET_SHOW_TIME = 1.5 -- Seconds after animation begins to show the rocket
  499. local ROCKET_HIDE_TIME = 2.2 -- Seconds after animation begins to hide the rocket
  500.  
  501. -----------------
  502. --| Variables |--
  503. -----------------
  504.  
  505. local Tool = script.Parent
  506. local ToolHandle = Tool.Handle
  507.  
  508. local MyModel = nil
  509. local ReloadRocket = nil
  510.  
  511. local StillEquipped = false
  512.  
  513. -----------------
  514. --| Functions |--
  515. -----------------
  516.  
  517. local function MakeReloadRocket()
  518. local reloadRocket = Instance.new('Part')
  519. reloadRocket.Name = "Ammo"
  520. reloadRocket.Transparency = 1
  521. reloadRocket.FormFactor = Enum.FormFactor.Custom --NOTE: This must be done before changing Size
  522. reloadRocket.Size = Vector3.new() -- As small as possible
  523.  
  524. local mesh = Instance.new('SpecialMesh', reloadRocket)
  525. mesh.MeshId = ROCKET_MESH_ID
  526. mesh.Scale = ROCKET_MESH_SCALE
  527. mesh.TextureId = ToolHandle.Mesh.TextureId
  528.  
  529. return reloadRocket
  530. end
  531.  
  532. local function OnEquipped()
  533. MyModel = Tool.Parent
  534. ReloadRocket = MakeReloadRocket()
  535. end
  536.  
  537. local function OnChanged(property)
  538. if property == 'Enabled' and Tool.Enabled == false then
  539. -- Show the next rocket going into the launcher
  540. StillEquipped = true
  541. wait(ROCKET_SHOW_TIME)
  542. if StillEquipped then
  543. local leftArm = MyModel:FindFirstChild('Left Arm')
  544. if leftArm then
  545. local weld = ReloadRocket:FindFirstChild('Weld')
  546. if not weld then
  547. weld = Instance.new('Weld')
  548. weld.Part0 = leftArm
  549. weld.Part1 = ReloadRocket
  550. weld.C1 = CFrame.new(Vector3.new(0, 1, 0))
  551. weld.Parent = ReloadRocket
  552. end
  553. ReloadRocket.Parent = MyModel
  554. end
  555. wait(ROCKET_HIDE_TIME - ROCKET_SHOW_TIME)
  556. if StillEquipped and ReloadRocket.Parent == MyModel then
  557. ReloadRocket.Parent = nil
  558. end
  559. end
  560. end
  561. end
  562.  
  563. local function OnUnequipped()
  564. StillEquipped = false
  565. ReloadRocket:Destroy()
  566. ReloadRocket = nil
  567. end
  568.  
  569. --------------------
  570. --| Script Logic |--
  571. --------------------
  572.  
  573. Tool.Equipped:connect(OnEquipped)
  574. Tool.Changed:connect(OnChanged)
  575. Tool.Unequipped:connect(OnUnequipped)
  576.  
  577. end))
  578. Part13.Name = "RPG-7"
  579. Part13.Parent = Tool0
  580. Part13.Rotation = Vector3.new(92.1199951, 62, -91.8699951)
  581. Part13.CanCollide = false
  582. Part13.FormFactor = Enum.FormFactor.Symmetric
  583. Part13.Size = Vector3.new(1, 1, 4)
  584. Part13.CFrame = CFrame.new(-71.2503738, 13.141613, 24.1718769, -0.0153171355, 0.469224393, 0.882945538, 0.00813870504, 0.883078873, -0.469153672, -0.99984926, -5.7471425e-08, -0.0173451193)
  585. Part13.BottomSurface = Enum.SurfaceType.Smooth
  586. Part13.TopSurface = Enum.SurfaceType.Smooth
  587. Part13.Position = Vector3.new(-71.2503738, 13.141613, 24.1718769)
  588. Part13.Orientation = Vector3.new(27.9799995, 91.1299973, 0.529999971)
  589. SpecialMesh14.Parent = Part13
  590. SpecialMesh14.MeshId = "http://www.roblox.com/asset/?id=88742477"
  591. SpecialMesh14.Scale = Vector3.new(2.5, 2.5, 2.5)
  592. SpecialMesh14.TextureId = "http://www.roblox.com/asset/?id=88745396"
  593. SpecialMesh14.MeshType = Enum.MeshType.FileMesh
  594. SpecialMesh14.Scale = Vector3.new(2.5, 2.5, 2.5)
  595. Script15.Name = "UltimateWeld"
  596. Script15.Parent = Tool0
  597. table.insert(cors,sandbox(Script15,function()
  598. --DO NOT USE BOTH WELDING SCRIPTS PROVIDED BY THIS MODEL
  599. --The regular script is recommended
  600.  
  601.  
  602.  
  603. --[[
  604. Prevents welds from breaking/transforming when player uses the tool
  605. This recreates the EXACT weld every time
  606. This also prevents lag build up by clearing old welds, the tradition weld script just keeps making new
  607. ones, which can lead to weapons have crazy amounts of welds that dont work (I saw 6000 in a weapon once)
  608. ]]
  609.  
  610. --[[Usage
  611. 1. Remove Old welding script (optional, only if updating a weapon and that weapon does not rely on that script)
  612. 2. Anchor all parts of tool and put inside of a tool object
  613. 3. Place this script in that tool (make sure you do this AFTER step 2, otherwise it may fail)
  614. 4. Treat like normal tool, nothing special has to be done with it
  615. ]]
  616.  
  617. --[[The local script included in this model can only be used if
  618. 1. The weapon is being placed in the players backpack first (i.e. the weapon is in starterpack and moves to player backpack)
  619. OR
  620. 2. The weapon is previously welded (weapon can be placed in workspace and picked up then)
  621. ]]
  622. repeat wait() until script.Parent:FindFirstChild("Handle")
  623. local welds={}
  624. function ClearOldWelds(tbl)
  625. for _,v in pairs(tbl) do
  626. if v:IsA('Weld') then
  627. v:Destroy()
  628. end
  629. end
  630. end
  631.  
  632. function Equipped()
  633. local handle=script.Parent:FindFirstChild('Handle')
  634. if not handle then return end
  635. local tble=handle:GetChildren()
  636. for _,v in pairs(script.Parent:GetChildren()) do
  637. if v:IsA('BasePart') and v~=handle then
  638. local c1
  639. for _1,v1 in pairs(welds) do
  640. if _1==v then
  641. c1=v1
  642. break
  643. end
  644. end
  645. if not c1 then
  646. welds[v]=v.CFrame:inverse()*handle.CFrame
  647. v.Anchored=false
  648. c1=welds[v]
  649. end
  650. local weld=Instance.new('Weld')
  651. weld.Part0=handle
  652. weld.Part1=v
  653. weld.C0=CFrame.new()
  654. weld.C1=c1
  655. weld.Parent=handle
  656. end
  657. end
  658. ClearOldWelds(tble)
  659. handle.Anchored=false
  660. end
  661. Equipped()
  662. script.Parent.Equipped:connect(Equipped)
  663.  
  664. --Made by DonnyTheDemented
  665.  
  666. end))
  667. Script16.Name = "Welding"
  668. Script16.Parent = Tool0
  669. table.insert(cors,sandbox(Script16,function()
  670. function Weld(x,y)
  671. local W = Instance.new("Weld")
  672. W.Part0 = x
  673. W.Part1 = y
  674. local CJ = CFrame.new(x.Position)
  675. local C0 = x.CFrame:inverse()*CJ
  676. local C1 = y.CFrame:inverse()*CJ
  677. W.C0 = C0
  678. W.C1 = C1
  679. W.Parent = x
  680. end
  681.  
  682. function Get(A)
  683. if A.className == "Part" then
  684. Weld(script.Parent.Handle, A)
  685. A.Anchored = false
  686. else
  687. local C = A:GetChildren()
  688. for i=1, #C do
  689. Get(C[i])
  690. end
  691. end
  692. end
  693.  
  694. function Finale()
  695. Get(script.Parent)
  696. end
  697.  
  698. script.Parent.Equipped:connect(Finale)
  699. script.Parent.Unequipped:connect(Finale)
  700. Finale()
  701. end))
  702. LocalScript17.Name = "BackupWeld"
  703. LocalScript17.Parent = Tool0
  704. table.insert(cors,sandbox(LocalScript17,function()
  705. function Weld(x,y)
  706. local W = Instance.new("Weld")
  707. W.Part0 = x
  708. W.Part1 = y
  709. local CJ = CFrame.new(x.Position)
  710. local C0 = x.CFrame:inverse()*CJ
  711. local C1 = y.CFrame:inverse()*CJ
  712. W.C0 = C0
  713. W.C1 = C1
  714. W.Parent = x
  715. end
  716.  
  717. function Get(A)
  718. if A.className == "Part" then
  719. Weld(script.Parent.Handle, A)
  720. A.Anchored = false
  721. else
  722. local C = A:GetChildren()
  723. for i=1, #C do
  724. Get(C[i])
  725. end
  726. end
  727. end
  728.  
  729. function Finale()
  730. Get(script.Parent)
  731. end
  732.  
  733. script.Parent.Equipped:connect(Finale)
  734. script.Parent.Unequipped:connect(Finale)
  735. Finale()
  736. end))
  737. for i,v in pairs(mas:GetChildren()) do
  738. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  739. pcall(function() v:MakeJoints() end)
  740. end
  741. mas:Destroy()
  742. for i,v in pairs(cors) do
  743. spawn(function()
  744. pcall(v)
  745. end)
  746. end
Add Comment
Please, Sign In to add comment