Advertisement
Fefio92142

Untitled

Mar 13th, 2017
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.18 KB | None | 0 0
  1. CONFIG SCRIPT
  2.  
  3. local tool, player = script.Parent, game.Players.LocalPlayer return {
  4.  
  5. ToolName = nil;
  6. ToolIcon = nil;
  7. ToolDesc = nil;
  8.  
  9. AmmoClip = 30;
  10. AmmoTotal = 150;
  11. AmmoLimited = true;
  12.  
  13. SpreadBase = 0.9;
  14.  
  15. ReloadDuration = 3;
  16. ReloadWhenEmpty = true;
  17. ReloadUnequipped = true;
  18.  
  19. FireRate = 0.13;
  20. FireAuto = true;
  21. FireBurst = false;
  22. FireMulti = 1;
  23.  
  24. DamageDefault = 10;
  25. DamageSpecific = {["Head"] = 10; ["Handle"] = 10};
  26. DamageNeutrals = true;
  27. DamageFriendly = false;
  28.  
  29. CursorEquipping = "rbxasset://textures\\GunCursor.png";
  30. CursorReloading = "rbxasset://textures\\GunWaitCursor.png";
  31.  
  32. HitSoundOn = false;
  33. HitSoundAsset = "rbxasset://sounds\\metalgrass2.mp3";
  34.  
  35. RayOriginOffset = CFrame.new(0,-0.75,0);
  36. RayMaxDistance = 999;
  37.  
  38. ReflectionEnabled = true;
  39. ReflectionLimit = 4;
  40.  
  41. LeftArmWeldC1 = nil;
  42. RightArmWeldC1 = nil;
  43.  
  44. ProjectileOriginOffset = CFrame.new(1, 0, 0);
  45.  
  46. }
  47.  
  48. wait(1)
  49.  
  50. repeat wait() until game.Players.LocalPlayer.Character
  51.  
  52. local player = game.Players.LocalPlayer
  53. local character = player.Character
  54. local backpack = player.Backpack
  55.  
  56. local debris = game:GetService('Debris')
  57. local create = assert(LoadLibrary('RbxUtility')).Create
  58. local storage = game:GetService('ReplicatedStorage'):findFirstChild("RCLStorage")
  59.  
  60. local filteringEnabled = workspace.FilteringEnabled
  61. local ignoreModel = nil
  62. local loadedTools = {}
  63. local connections = {}
  64. local handles = {}
  65.  
  66. local firing
  67. local mouseDown
  68. local hitSound
  69. local deathConnection
  70. local creatorTag
  71. local leftArmWeld
  72. local rightArmWeld
  73.  
  74. -- For optimization purposes
  75. local multiShot
  76. local serverDmg
  77. local ammoLimit
  78.  
  79. local ray = Ray.new
  80. local cframe = CFrame.new
  81. local mathAbs = math.abs
  82. local vector3 = Vector3.new
  83. local mathRandom = math.random
  84.  
  85. local projectilePart = create("Part"){
  86. Size = vector3(1, 1, 1);
  87. Anchored = true;
  88. FormFactor = 0;
  89. CanCollide = false;
  90. TopSurface = 0;
  91. BottomSurface = 0;
  92. BrickColor = player.TeamColor;
  93. }
  94.  
  95. create("SpecialMesh"){
  96. Parent = projectilePart;
  97. MeshType = "Brick";
  98. Scale = vector3(.2, .2, 1);
  99. }
  100.  
  101. if not storage then
  102. creatorTag = create("ObjectValue"){
  103. Name = "creator";
  104. Value = player;
  105. }
  106. else
  107. ignoreModel = workspace:findFirstChild("IgnoreContainer") or nil
  108. end
  109.  
  110. local function getValueClient(tool, name)
  111. return tool.Config[name].Value
  112. end
  113.  
  114. local function setValueClient(tool, name, value)
  115. tool.Config[name].Value = value
  116. end
  117.  
  118. local function getValueServer(tool, name)
  119. if filteringEnabled then
  120. return storage.Remotes.GetFunction:InvokeServer(tool.Config[name])
  121. end
  122. end
  123.  
  124. local function setValueServer(tool, name, value)
  125. if filteringEnabled then
  126. storage.Remotes.SetEvent:FireServer(tool.Config[name], value)
  127. end
  128. end
  129.  
  130. local function waitForChildren(parent, children)
  131. for _, name in pairs(children) do
  132. while not parent:findFirstChild(name) do
  133. wait()
  134. end
  135. end
  136. end
  137.  
  138. local function waitForConfig(tool)
  139. while not tool:findFirstChild("Config") do
  140. wait()
  141. end
  142. end
  143.  
  144. local function playSound(tool, name)
  145. if tool and tool:findFirstChild("Handle") then
  146. local sound = tool.Handle:findFirstChild(name)
  147. if sound then
  148. sound:Play()
  149. if filteringEnabled then
  150. storage.Remotes.PlayEvent:FireServer(sound)
  151. end
  152. end
  153. end
  154. end
  155.  
  156. local function isPlayerAlive()
  157. if player.Character and player.Character:findFirstChild("Humanoid") and player.Character.Humanoid.Health > 0 then
  158. return true
  159. else
  160. return false
  161. end
  162. end
  163.  
  164. local function getOverride(name)
  165. if storage and storage:findFirstChild("Settings") and storage.Settings:findFirstChild(name) then
  166. return true
  167. else
  168. return false
  169. end
  170. end
  171.  
  172. local function targetFilter(hitPart, humanoid, config)
  173.  
  174. local target = game.Players:GetPlayerFromCharacter(humanoid.Parent)
  175.  
  176. local dealDamage = target and (target.TeamColor ~= player.TeamColor or (config.DamageFriendly or getOverride("FriendlyFire"))) or (not target and config.DamageNeutrals)
  177.  
  178. if dealDamage then
  179.  
  180. local damage = config.DamageSpecific[hitPart.Name] or config.DamageDefault
  181.  
  182. if serverDmg then
  183. storage.Remotes.HitEvent:FireServer(humanoid, damage)
  184. hitSound:Play()
  185. else
  186. humanoid:TakeDamage(damage)
  187. hitSound:Play()
  188. end
  189.  
  190. if not storage and target then
  191. if not humanoid:findFirstChild('creator') then
  192. local tag = creatorTag:Clone()
  193. tag.Parent = humanoid
  194. debris:AddItem(tag, 0.5)
  195. end
  196. end
  197.  
  198. end
  199. end
  200.  
  201. local function raycast(origin, direction, ignore)
  202. return workspace:FindPartOnRayWithIgnoreList(ray(origin, direction), ignore)
  203. end
  204.  
  205. -- Parameter simple is set to true for projectiles replicated through filteringEnabled and for reflected projectiles
  206. local function spawnProjectile(origin, hitPosition, shooter, simple)
  207.  
  208. local bulletLength, orientation = (origin - hitPosition).magnitude, cframe(origin, hitPosition)
  209.  
  210. if simple then
  211.  
  212. local laser1 = projectilePart:clone()
  213.  
  214. if shooter then
  215. laser1.BrickColor = shooter.TeamColor
  216. else
  217. laser1.BrickColor = player.TeamColor
  218. end
  219.  
  220. laser1.CFrame = orientation * cframe(0,0, -bulletLength*.5)
  221. laser1.Mesh.Scale = vector3(.2, .2 , bulletLength)
  222.  
  223. laser1.Parent = ignoreModel == nil and workspace or ignoreModel
  224. debris:AddItem(laser1, .06)
  225.  
  226. else
  227.  
  228. local laser1, laser2 = projectilePart:clone(), projectilePart:clone()
  229.  
  230. if shooter then
  231. laser1.BrickColor = shooter.TeamColor
  232. laser2.BrickColor = shooter.TeamColor
  233. else
  234. laser1.BrickColor = player.TeamColor
  235. laser2.BrickColor = player.TeamColor
  236. end
  237.  
  238. laser1.CFrame = orientation * cframe(0,0,-bulletLength*.75)
  239. laser2.CFrame = orientation * cframe(0,0, -bulletLength*.25)
  240.  
  241. laser1.Mesh.Scale = vector3(.2, .2 , bulletLength*.5)
  242. laser2.Mesh.Scale = vector3(.2, .2, bulletLength*.5)
  243.  
  244. laser1.Parent = ignoreModel == nil and workspace or ignoreModel
  245. laser2.Parent = ignoreModel == nil and workspace or ignoreModel
  246.  
  247. debris:AddItem(laser2, .03)
  248. debris:AddItem(laser1, .06)
  249.  
  250. end
  251. end
  252.  
  253. local function getReflectionionDirection(normal, direction)
  254. local n = normal.unit
  255. local v = direction.unit
  256. return 2*(n:Dot(-1*v))*n + v
  257. end
  258.  
  259. local function getSurfaceNormal(hitPart, hitPosition)
  260.  
  261. local relativeObjectSpace = hitPart.CFrame:pointToObjectSpace(hitPosition)/hitPart.Size
  262. local absoluteObjectSpace = vector3(mathAbs(relativeObjectSpace.x),mathAbs(relativeObjectSpace.y),mathAbs(relativeObjectSpace.z))
  263. local largestVector
  264.  
  265. if absoluteObjectSpace.x > absoluteObjectSpace.y and absoluteObjectSpace.x > absoluteObjectSpace.z then
  266. largestVector = vector3(relativeObjectSpace.x,0,0).unit
  267. elseif absoluteObjectSpace.y > absoluteObjectSpace.z then
  268. largestVector = vector3(0,relativeObjectSpace.y,0).unit
  269. else
  270. largestVector = vector3(0,0,relativeObjectSpace.z).unit
  271. end
  272.  
  273. return (hitPart.CFrame - hitPart.Position):pointToWorldSpace(largestVector)
  274.  
  275. end
  276.  
  277. local function fire(tool, mouse, origin, direction, config, run)
  278.  
  279. local run = run or 1
  280. local aimPoint = mouse.hit.p
  281. local distance = (origin - aimPoint).magnitude
  282. local minSpread = -(config.SpreadBase) * distance
  283. local maxSpread = (config.SpreadBase) * distance
  284.  
  285. if run < 2 then
  286. direction = (vector3((aimPoint.x) + (mathRandom(minSpread, maxSpread)/100), (aimPoint.y) + (mathRandom(minSpread, maxSpread)/100), (aimPoint.z) + (mathRandom(minSpread, maxSpread)/100)) - origin).unit * 999
  287. end
  288.  
  289. local hitPart, hitPosition = raycast(origin, direction, {player.Character, ignoreModel})
  290. local projectileOrigin = run < 2 and (tool.Handle.CFrame * config.ProjectileOriginOffset).p or origin
  291.  
  292. spawnProjectile(projectileOrigin, hitPosition, nil, run > 1 and true)
  293. if filteringEnabled then
  294. storage.Remotes.FireEvent:FireServer(projectileOrigin, hitPosition)
  295. end
  296.  
  297. if hitPart then
  298.  
  299. local humanoid = hitPart.Parent:FindFirstChild("Humanoid") or hitPart.Parent.Parent:FindFirstChild("Humanoid")
  300.  
  301. if humanoid then
  302. targetFilter(hitPart, humanoid, config)
  303. elseif hitPart.Reflectance >= 1 and config.ReflectionEnabled and run < config.ReflectionLimit then
  304. local normal = getSurfaceNormal(hitPart, hitPosition)
  305. local newDirection = getReflectionionDirection(normal, direction)
  306. fire(tool, mouse, hitPosition, newDirection * 999, config, run + 1)
  307. end
  308.  
  309. end
  310.  
  311. end
  312.  
  313. local function shoot(tool, mouse, config)
  314.  
  315. local origin = (player.Character.Head.CFrame * config.RayOriginOffset).p
  316. local direction = (mouse.hit.p - origin).unit * 999
  317.  
  318. if multiShot then
  319. for i = 1, config.FireBurst and 3 or config.FireMulti do
  320. spawn(fire(tool, mouse, origin, direction, config))
  321. end
  322. else
  323. fire(tool, mouse, origin, direction, config)
  324. end
  325.  
  326. end
  327.  
  328. local lastReloadAttempt = time()
  329.  
  330. local function reload(tool, mouse, config)
  331.  
  332. -- Prevents spamming the server
  333. if filteringEnabled then
  334. if (time() - lastReloadAttempt) < 1 then
  335. return
  336. else
  337. lastReloadAttempt = time()
  338. end
  339. end
  340.  
  341. if not getValueClient(tool, "Reloading") and getValueClient(tool, "AmmoClip") ~= config.AmmoClip then
  342.  
  343. if ammoLimit and getValueClient(tool, "AmmoStored") <= 0 then
  344. playSound(tool, "Empty")
  345. return
  346. end
  347.  
  348. setValueClient(tool, "Reloading", true)
  349. setValueClient(tool, "Firing", false)
  350.  
  351. playSound(tool, "Reload")
  352.  
  353. mouse.Icon = player:findFirstChild("CursorReloading") and player.CursorReloading.Value or config.CursorReloading
  354.  
  355. if not config.ToolName then
  356. tool.Name = "[REL]"
  357. end
  358.  
  359. local ammoStored = nil
  360.  
  361. if ammoLimit and filteringEnabled then
  362. spawn(function()
  363. ammoStored = getValueServer(tool, "AmmoStored")
  364. end)
  365. else
  366. ammoStored = getValueClient(tool, "AmmoStored")
  367. end
  368.  
  369. wait(config.ReloadDuration)
  370.  
  371. if not config.ReloadUnequipped and not getValueClient(tool, "Equipped") then
  372. return
  373. end
  374.  
  375. if not ammoLimit then
  376.  
  377. setValueClient(tool, "AmmoClip", config.AmmoClip)
  378.  
  379. else
  380.  
  381. while not ammoStored do
  382. wait()
  383. end
  384.  
  385. local ammoClip = getValueClient(tool, "AmmoClip")
  386.  
  387. if ammoStored < config.AmmoClip then
  388.  
  389. if ammoClip + ammoStored > config.AmmoClip then
  390.  
  391. setValueClient(tool, "AmmoClip", config.AmmoClip)
  392.  
  393. if filteringEnabled then
  394. setValueServer(tool, "AmmoStored", ammoStored - (config.AmmoClip - ammoClip))
  395. else
  396. setValueClient(tool, "AmmoStored", ammoStored - (config.AmmoClip - ammoClip))
  397. end
  398.  
  399. else
  400.  
  401. setValueClient(tool, "AmmoClip", ammoClip + ammoStored)
  402.  
  403. if filteringEnabled then
  404. setValueServer(tool, "AmmoStored", 0)
  405. else
  406. setValueClient(tool, "AmmoStored", 0)
  407. end
  408.  
  409. end
  410.  
  411. else
  412.  
  413. setValueClient(tool, "AmmoClip", config.AmmoClip)
  414.  
  415. if filteringEnabled then
  416. setValueServer(tool, "AmmoStored", ammoStored - (config.AmmoClip - ammoClip))
  417. else
  418. setValueClient(tool, "AmmoStored", ammoStored - (config.AmmoClip - ammoClip))
  419. end
  420.  
  421. end
  422.  
  423. end
  424.  
  425. mouse.Icon = player:findFirstChild("CursorEquipping") and player.CursorEquipping.Value or config.CursorEquipping
  426.  
  427. if not config.ToolName then
  428. tool.Name = "["..getValueClient(tool, "AmmoClip").."]"
  429. end
  430.  
  431. setValueClient(tool, "Reloading", false)
  432.  
  433. end
  434.  
  435. end
  436.  
  437. local function button1Down(tool, mouse, config)
  438.  
  439. mouseDown = true
  440.  
  441. if not isPlayerAlive() then
  442. return
  443. end
  444.  
  445. waitForConfig(tool)
  446.  
  447. if not getValueClient(tool, "Firing") then
  448.  
  449. -- Auto
  450. if config.FireAuto then
  451.  
  452. setValueClient(tool, "Firing", true)
  453.  
  454. while mouseDown and not getValueClient(tool, "Reloading") and getValueClient(tool, "AmmoClip")>0 do
  455.  
  456. setValueClient(tool, "AmmoClip", getValueClient(tool, "AmmoClip") - 1)
  457.  
  458. shoot(tool, mouse, config)
  459.  
  460. if not config.ToolName then
  461. tool.Name = "["..getValueClient(tool, "AmmoClip").."]"
  462. end
  463.  
  464. playSound(tool, "Fire")
  465.  
  466. wait(config.FireRate)
  467.  
  468. end
  469.  
  470. setValueClient(tool, "Firing", false)
  471.  
  472. if getValueClient(tool, "AmmoClip") <= 0 then
  473. if config.ReloadWhenEmpty then
  474. reload(tool, mouse, config)
  475. else
  476. playSound(tool, "Empty")
  477. end
  478. end
  479.  
  480. -- Semi
  481. else
  482.  
  483. if not getValueClient(tool, "Firing") and not getValueClient(tool, "Reloading") and getValueClient(tool, "AmmoClip") > 0 then
  484.  
  485. setValueClient(tool, "Firing", true)
  486.  
  487. setValueClient(tool, "AmmoClip", getValueClient(tool, "AmmoClip") - 1)
  488.  
  489. shoot(tool, mouse, config)
  490.  
  491. if not config.ToolName then
  492. tool.Name = "["..getValueClient(tool, "AmmoClip").."]"
  493. end
  494.  
  495. playSound(tool, "Fire")
  496.  
  497. wait(config.FireRate)
  498.  
  499. setValueClient(tool, "Firing", false)
  500.  
  501. elseif getValueClient(tool, "AmmoClip")<=0 and not getValueClient(tool, "Firing") then
  502.  
  503. if config.ReloadWhenEmpty then
  504. reload(tool, mouse, config)
  505. else
  506. playSound(tool, "Empty")
  507. end
  508.  
  509. end
  510.  
  511. end
  512.  
  513. end
  514. end
  515.  
  516. local function button1Up(tool, mouse, config)
  517. mouseDown = false
  518. end
  519.  
  520. local function keyDown(tool, mouse, key, config)
  521. if key:lower() == 'r' then
  522. reload(tool, mouse, config)
  523. end
  524. end
  525.  
  526. local function unequipped(tool, config)
  527.  
  528. if not isPlayerAlive() then
  529. return
  530. end
  531.  
  532. waitForConfig(tool)
  533.  
  534. mouseDown = false
  535.  
  536. setValueClient(tool, "Firing", false)
  537.  
  538. if deathConnection then
  539. deathConnection:disconnect()
  540. end
  541.  
  542. if (not config.ToolName and not getValueClient(tool, "Reloading")) or not config.ReloadUnequipped then
  543. tool.Name = "["..getValueClient(tool, "AmmoClip").."]"
  544. end
  545.  
  546. setValueClient(tool, "Equipped", false)
  547.  
  548. end
  549.  
  550. local function equipped(tool, mouse, config)
  551.  
  552. if not isPlayerAlive() then
  553. return
  554. end
  555.  
  556. waitForConfig(tool)
  557.  
  558. deathConnection = character.Humanoid.Died:connect(function()
  559. tool:Destroy()
  560. for _, connection in pairs(connections) do
  561. pcall(function()
  562. connection:disconnect()
  563. end)
  564. end
  565. for _, remainingTool in pairs(backpack:GetChildren()) do
  566. remainingTool:Destroy()
  567. end
  568. end)
  569.  
  570. -- Optimization
  571. multiShot = config.FireMulti > 1 and true or config.FireBurst
  572. serverDmg = storage and storage.Remotes:findFirstChild("HitEvent") and true or false
  573.  
  574. if getOverride("InfiniteAmmo") then
  575. ammoLimit = false
  576. else
  577. ammoLimit = config.AmmoLimited
  578. end
  579.  
  580. if hitSound then
  581. hitSound.Volume = getOverride("HitSoundsEnabled") and 1 or (config.HitSoundsOn and 1 or 0);
  582. hitSound.SoundId = player:findFirstChild("HitSoundAsset") and player.HitSoundAsset.Value or config.HitSoundAsset;
  583. else
  584. hitSound = create("Sound"){
  585. Name = "HitSound";
  586. Volume = getOverride("HitSoundsEnabled") and 1 or (config.HitSoundsOn and 1 or 0);
  587. SoundId = player:findFirstChild("HitSoundAsset") and player.HitSoundAsset.Value or config.HitSoundAsset;
  588. Pitch = 1;
  589. Parent = player.PlayerGui
  590. }
  591. end
  592.  
  593. if not config.ToolName and not getValueClient(tool, "Reloading") then
  594. tool.Name = "["..getValueClient(tool, "AmmoClip").."]"
  595. end
  596.  
  597. if config.ToolIcon then
  598. tool.TextureId = config.ToolIcon
  599. end
  600.  
  601. if config.ToolDesc then
  602. tool.ToolTip = config.ToolDesc
  603. end
  604.  
  605. mouse.Icon = player:findFirstChild("CursorEquipping") and player.CursorEquipping.Value or config.CursorEquipping
  606.  
  607. mouse.Button1Down:connect(function() button1Down(tool, mouse, config) end)
  608. mouse.Button1Up:connect(function() button1Up(tool, mouse, config) end)
  609. mouse.KeyDown:connect(function(key) keyDown(tool, mouse, key, config) end)
  610.  
  611. setValueClient(tool, "Equipped", true)
  612.  
  613. end
  614.  
  615. local function isToolLoaded(parent)
  616. for _, child in pairs(loadedTools) do
  617. if parent == child then
  618. return true
  619. end
  620. end
  621. return false
  622. end
  623.  
  624. local function scanTool(parent, dropped)
  625.  
  626. if parent:IsA("Tool") then
  627.  
  628. local configModule = parent:findFirstChild("Config")
  629.  
  630. if configModule and configModule:IsA("ModuleScript") and not isToolLoaded(parent) then
  631.  
  632. spawn(function()
  633.  
  634. table.insert(loadedTools, parent)
  635.  
  636. local tool = parent
  637. local config = require(configModule)
  638.  
  639. tool.CanBeDropped = false
  640. table.insert(handles, tool:WaitForChild("Handle"))
  641.  
  642. waitForChildren(tool:WaitForChild("Config"), {"AmmoClip","AmmoStored","AmmoTotal"})
  643.  
  644. setValueClient(tool, "AmmoClip", config.AmmoClip)
  645.  
  646. setValueServer(tool, "AmmoStored", config.AmmoTotal)
  647. setValueClient(tool, "AmmoStored", config.AmmoTotal)
  648.  
  649. setValueServer(tool, "AmmoTotal", config.AmmoTotal)
  650. setValueClient(tool, "AmmoTotal", config.AmmoTotal)
  651.  
  652. -- Equip routine
  653. table.insert(connections, tool.Equipped:connect(function(mouse)
  654. waitForChildren(tool:WaitForChild("Config"), {"AmmoClip","AmmoStored","AmmoTotal","Equipped","Reloading","Firing"})
  655. equipped(tool, mouse, config)
  656. end))
  657.  
  658. -- Unequip routine
  659. table.insert(connections, tool.Unequipped:connect(function()
  660. unequipped(tool, config)
  661. end))
  662.  
  663. -- Adding arm welds
  664. table.insert(connections, tool.Equipped:connect(function()
  665.  
  666. waitForChildren(character, {"Torso", "Left Arm", "Right Arm"})
  667.  
  668. local torso = character:findFirstChild("Torso")
  669. local leftArm = character:findFirstChild("Left Arm")
  670. local rightArm = character:findFirstChild("Right Arm")
  671.  
  672. waitForChildren(torso, {"Left Shoulder", "Right Shoulder"})
  673.  
  674. local leftShoulder = torso:findFirstChild("Left Shoulder")
  675. local rightShoulder = torso:findFirstChild("Right Shoulder")
  676.  
  677. leftShoulder.Part1 = nil
  678. rightShoulder.Part1 = nil
  679.  
  680. if filteringEnabled then
  681. if config.LeftArmWeldC1 or config.RightArmWeldC1 then
  682. storage.Remotes.WeldEvent:FireServer(false, true, config.LeftArmWeldC1, config.RightArmWeldC1)
  683. else
  684. storage.Remotes.WeldEvent:FireServer(false)
  685. end
  686. end
  687.  
  688. local Weld = Instance.new("Weld")
  689.  
  690. leftArmWeld = Weld:Clone()
  691. leftArmWeld.Name = "LocalLeftArmWeld"
  692. leftArmWeld.Part0 = torso
  693. leftArmWeld.Part1 = leftArm
  694. leftArmWeld.C1 = config.LeftArmWeldC1 or cframe(0.8,0.5,0.4) * CFrame.Angles(math.rad(270), math.rad(40), 0)
  695. leftArmWeld.Parent = torso
  696.  
  697. rightArmWeld = Weld:Clone()
  698. rightArmWeld.Name = "LocalRightArmWeld"
  699. rightArmWeld.Part0 = torso
  700. rightArmWeld.Part1 = rightArm
  701. rightArmWeld.C1 = config.RightArmWeldC1 or cframe(-1.2,0.5,0.4) * CFrame.Angles(math.rad(270), math.rad(-5), 0)
  702. rightArmWeld.Parent = torso
  703.  
  704. end))
  705.  
  706. -- Removing arm welds
  707. table.insert(connections, tool.Unequipped:connect(function()
  708.  
  709. waitForChildren(character, {"Torso", "Left Arm", "Right Arm"})
  710.  
  711. local torso = character:findFirstChild("Torso")
  712. local leftArm = character:findFirstChild("Left Arm")
  713. local rightArm = character:findFirstChild("Right Arm")
  714.  
  715. waitForChildren(torso, {"Left Shoulder", "Right Shoulder"})
  716.  
  717. local leftShoulder = torso:findFirstChild("Left Shoulder")
  718. local rightShoulder = torso:findFirstChild("Right Shoulder")
  719.  
  720. if filteringEnabled then
  721. storage.Remotes.WeldEvent:FireServer(true)
  722. if torso:findFirstChild("LeftArmWeld") then
  723. torso["LeftArmWeld"].Part1 = nil
  724. end
  725. if torso:findFirstChild("RightArmWeld") then
  726. torso["RightArmWeld"].Part1 = nil
  727. end
  728. end
  729.  
  730. leftArmWeld.Part1 = nil
  731. rightArmWeld.Part1 = nil
  732.  
  733. leftShoulder.Part1 = leftArm
  734. rightShoulder.Part1 = rightArm
  735.  
  736. if leftArmWeld then
  737. leftArmWeld:Destroy()
  738. end
  739.  
  740. if rightArmWeld then
  741. rightArmWeld:Destroy()
  742. end
  743.  
  744. end))
  745.  
  746. end)
  747. end
  748. end
  749. end
  750.  
  751. if filteringEnabled then
  752.  
  753. storage.Remotes.FireEvent.OnClientEvent:connect(function(shooter, origin, hitPosition)
  754. if shooter.Name ~= player.Name then
  755. spawnProjectile(origin, hitPosition, shooter, true)
  756. end
  757. end)
  758.  
  759. storage.Remotes.PlayEvent.OnClientEvent:connect(function(shooter, sound)
  760. if shooter.Name ~= player.Name and sound then
  761. sound:Play()
  762. end
  763. end)
  764.  
  765. end
  766.  
  767. player:WaitForChild("Backpack").ChildAdded:connect(function(child)
  768. scanTool(child, true)
  769. end)
  770.  
  771. for _, parent in pairs(player.Backpack:GetChildren()) do
  772. scanTool(parent)
  773. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement