Advertisement
Godofadmin1337

Eye of the all seeking LAZER

Nov 1st, 2017
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.77 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. LocalScript1 = Instance.new("LocalScript")
  20. Script2 = Instance.new("Script")
  21. Part3 = Instance.new("Part")
  22. SpecialMesh4 = Instance.new("SpecialMesh")
  23. Script5 = Instance.new("Script")
  24. ObjectValue6 = Instance.new("ObjectValue")
  25. ObjectValue7 = Instance.new("ObjectValue")
  26. Tool0.Name = "LaserSpecs"
  27. Tool0.Parent = mas
  28. Tool0.TextureId = "http://www.roblox.com/asset/?id=100449698"
  29. Tool0.GripForward = Vector3.new(-0, 1.31134158e-07, -1)
  30. Tool0.GripPos = Vector3.new(1.53999996, -1.27000034, -1.31999993)
  31. Tool0.GripUp = Vector3.new(0, 1, 1.31134158e-07)
  32. LocalScript1.Name = "SpotWeld_Main"
  33. LocalScript1.Parent = Tool0
  34. table.insert(cors,sandbox(LocalScript1,function()
  35. --local mDebugId = game.Workspace.DebugId.Value
  36. --game.Workspace.DebugId.Value = game.Workspace.DebugId.Value+1
  37. --print("Running swordscript <"..mDebugId..">")
  38.  
  39. -------------------------------------
  40. -- Makes an RBX::Lua Instance using
  41. -- a table of key-value pairs to
  42. -- initialize it. Values with numeric
  43. -- keys will be parented to the object
  44. -- and other values will be set
  45. -- as members of the object.
  46. function Create(ty)
  47. return function(data)
  48. local obj = Instance.new(ty)
  49. for k, v in pairs(data) do
  50. if type(k) == 'number' then
  51. v.Parent = obj
  52. else
  53. obj[k] = v
  54. end
  55. end
  56. return obj
  57. end
  58. end
  59.  
  60. ---------------------------------------
  61. -- Same as Make, but modifies an existing
  62. -- object rather than creating ones.
  63. function Modify(obj, data)
  64. for k, v in pairs(data) do
  65. if type(data) == 'number' then
  66. data.Parent = obj
  67. else
  68. data[k] = v
  69. end
  70. end
  71. return obj
  72. end
  73.  
  74. -----------------------------------------
  75. -- Creates a class which can be instantiated
  76. -- using `CreateCLASSNAME( ... )`.
  77. ---usage:
  78. --class'MyClass'(function(this, arg1)
  79. -- this.ClassMember = value
  80. -- function this.ClassMethod(...) ... end
  81. --end, function(def)
  82. -- def.StaticMember = value
  83. -- function def.StaticMethod(...) ... end
  84. --end)
  85. --local obj = CreateMyClass(arg1)
  86. ------------------------------------------
  87. local function class(name)
  88. local def = {}
  89. getfenv(0)[name] = def
  90. return function(ctor, static)
  91. local nctor = function(...)
  92. local this = {}
  93. if ctor then
  94. ctor(this, ...)
  95. end
  96. return this
  97. end
  98. getfenv(0)['Create'..name] = nctor
  99. if static then static(def) end
  100. end
  101. end
  102.  
  103.  
  104. ---------------------------------------------
  105. -- Signal class for custom-made events
  106. --API:
  107. -- Signal:connect(callback)
  108. -- Signal:fire(...)
  109. -- Signal:wait()
  110. ---------------------------------------------
  111. class'Signal'(function(this)
  112. local mListeners = {}
  113. local mWaitObject = Create'BoolValue'{}
  114.  
  115. function this:connect(func)
  116. local connection = {}
  117. function connection:disconnect()
  118. mListeners[func] = nil
  119. end
  120. mListeners[func] = connection
  121. return connection
  122. end
  123.  
  124. function this:fire(...)
  125. --print("Fire evt<"..tostring(this).."> from script<"..mDebugId..">")
  126. for func, conn in pairs(mListeners) do
  127. --print("-> "..tostring(func).."( ... )")
  128. func(...)
  129. end
  130. mWaitObject.Value = not mWaitObject.Value
  131. end
  132.  
  133. function this:wait()
  134. mWaitObject.Changed:wait()
  135. end
  136. end)
  137.  
  138.  
  139. --------------------------------------------------
  140. -- Bin class for cleaning up assets
  141. --API:
  142. -- Bin:add(func: Function, ident: String)
  143. -- Bin:clean(ident: String)
  144. -- Bin:cleanAll()
  145. --------------------------------------------------
  146. class'Bin'(function(this)
  147. local mGarbage = {}
  148.  
  149. function this:add(func, ident)
  150. ident = ident or '__unnamed'
  151. if not mGarbage[ident] then
  152. mGarbage[ident] = {}
  153. end
  154. mGarbage[ident][#mGarbage[ident]+1] = func
  155. end
  156.  
  157. function this:clean(ident)
  158. local listToCall = mGarbage[ident]
  159. if listToCall then
  160. for _, func in pairs(listToCall) do
  161. func()
  162. end
  163. mGarbage[ident] = nil
  164. end
  165. end
  166.  
  167. function this:cleanAll()
  168. for ident, list in pairs(mGarbage) do
  169. for _, func in pairs(list) do
  170. func()
  171. end
  172. mGarbage[ident] = nil
  173. end
  174. end
  175. end)
  176.  
  177.  
  178. -----------------------------------------------------
  179. -- AnimationProvider class for easy loading of
  180. -- animation assets into animationtracks once
  181. -- a humanoid is available.
  182. --API:
  183. -- AnimationProvider:registerAnimation(ident, assetid)
  184. -- AnimationProvider:setHumanoid(humanoid)
  185. -- AnimationProvider:setTool(tool)
  186. -- AnimationProvider:getAnimation(ident)
  187. -----------------------------------------------------
  188. class'AnimationProvider'(function(this)
  189. local mAnimations = {--[[ident => {AnimationId, CurrentTrack, CurrentAnim} ]]}
  190. local mCurrentHumanoid = nil
  191.  
  192. function this:registerAnimation(ident, assetid)
  193. --check for an existing copy of the anim
  194. local existingAnim = Tool.Tool:FindFirstChild('ANIM_'..ident)
  195.  
  196. --make the data for this anim
  197. local animdat = {
  198. AnimationId = assetid,
  199. CurrentAnim = existingAnim or Create'Animation'{
  200. Name = "ANIM_"..ident,
  201. AnimationId = assetid,
  202. },
  203. }
  204. mAnimations[ident] = animdat
  205.  
  206. --if there's a current tool, put it in there
  207. if Tool.Tool then
  208. Tool.HUGE_EQUIP_HACK = true
  209. animdat.CurrentAnim.Parent = Tool.Tool
  210. Tool.HUGE_EQUIP_HACK = false
  211. end
  212.  
  213. --if there's a humanoid load the animation track
  214. if mCurrentHumanoid then
  215. animdat.CurrentTrack = mCurrentHumanoid:LoadAnimation(animdat.CurrentAnim)
  216. end
  217. end
  218.  
  219. function this:setHumanoid(humanoid)
  220. mCurrentHumanoid = humanoid
  221. for _, anim in pairs(mAnimations) do
  222. anim.CurrentTrack = humanoid:LoadAnimation(anim.CurrentAnim)
  223. end
  224. end
  225.  
  226. function this:getAnimation(ident)
  227. local dat = mAnimations[ident]
  228. if not dat then error("Gear Fatal Error: Animation `"..ident.."` not found") end
  229. if not dat.CurrentTrack then
  230. error("Gear Fatal Error: No Humanoid for animation `"..ident.."` to run in")
  231. end
  232. return dat.CurrentTrack
  233. end
  234. end)
  235.  
  236.  
  237. ----------------------------------------------
  238. -- SoundProvider class
  239. -- functions similarily to the animationprovider
  240. ----------------------------------------------
  241. class'SoundProvider'(function(this)
  242. local mSounds = {}
  243.  
  244. function this:registerSound(ident, assetid, inpart)
  245. inpart = inpart or Tool.Tool:FindFirstChild('Handle')
  246. if not inpart then
  247. repeat
  248. inpart = Tool.Tool.ChildAdded:wait()
  249. until inpart.Name == 'Handle'
  250. end
  251. local existingSound = inpart:FindFirstChild('SOUND_'..ident)
  252. local sounddat = {
  253. SoundId = assetid,
  254. CurrentSound = existingSound or Create'Sound'{
  255. Name = 'SOUND_'..ident,
  256. SoundId = assetid,
  257. Parent = inpart,
  258. },
  259. }
  260. mSounds[ident] = sounddat
  261. end
  262.  
  263. function this:getSound(ident)
  264. local dat = mSounds[ident]
  265. if dat then
  266. return dat.CurrentSound
  267. end
  268. end
  269. end)
  270.  
  271.  
  272. ----------------------------------------------
  273. -- DebounceProvider class -- Prevent events
  274. -- from happening in too rapid succession
  275. ----------------------------------------------
  276. class'DebounceProvider'(function(this)
  277. local mFlagNameToLastTime = {}
  278.  
  279. function this:test(ident, delta)
  280. local t = tick()
  281. local lastTime = mFlagNameToLastTime[ident] or 0
  282. if delta then
  283. return (t-lastTime) > delta
  284. else
  285. return mFlagNameToLastTime[ident]
  286. end
  287. end
  288. function this:set(ident, state)
  289. if state then
  290. mFlagNameToLastTime[ident] = state
  291. elseif state == false then
  292. mFlagNameToLastTime[ident] = false
  293. else
  294. mFlagNameToLastTime[ident] = tick()
  295. end
  296. end
  297. end)
  298.  
  299.  
  300. function TagHumanoid(humanoid)
  301. if Tool.Player then
  302. local tag = Create'ObjectValue'{
  303. Name = "creator",
  304. Value = Tool.Player,
  305. Parent = humanoid,
  306. }
  307. game.Debris:AddItem(tag, 1)
  308. end
  309. end
  310.  
  311.  
  312. ------- wait for any event in a set of events to fire ------
  313. function WaitForAny(tb)
  314. local evt = tb
  315. local conn = {}
  316. local eventargs = nil
  317. local waitProxy = Create'BoolValue'{}
  318. for _, e in pairs(evt) do
  319. local c = e:connect(function(...)
  320. for _, c in pairs(conn) do
  321. c:disconnect()
  322. end
  323. eventargs = {...}
  324. waitProxy.Value = not waitProxy.Value
  325. end)
  326. conn[#conn+1] = c
  327. end
  328. --
  329. waitProxy.Changed:wait()
  330. --
  331. return unpack(eventargs)
  332. end
  333.  
  334.  
  335. ----------------------------------------------
  336.  
  337. local EmitterPart = nil
  338.  
  339. -- Tool singleton class
  340. --API:
  341. -- ...
  342. class'Tool'(nil, function(this)
  343. --need this here for the animationprovider to use
  344. this.HUGE_EQUIP_HACK = false
  345.  
  346. this.Bin = CreateBin()
  347. this.AnimationProvider = CreateAnimationProvider()
  348. this.DebounceProvider = CreateDebounceProvider()
  349. this.SoundProvider = CreateSoundProvider()
  350.  
  351. --general values
  352. this.Tool = script.Parent
  353. this.Player = nil
  354. this.Humanoid = nil
  355. this.Character = nil
  356.  
  357. --============ several flags for the gear
  358. --nothing
  359.  
  360. --some events
  361. this.Equipped = CreateSignal()
  362. this.Unequipped = CreateSignal()
  363. this.OwnerChange = CreateSignal()
  364.  
  365. --mouse utility events
  366. this.MouseClick = CreateSignal()
  367. this.MouseRelease = CreateSignal()
  368. this.MouseDoubleClick = CreateSignal()
  369. this.DoubleClickThreshold = 0.2
  370. this.MouseDown = false
  371. this.KeyDown = CreateSignal()
  372.  
  373. local mLastClickTime = 0
  374.  
  375. script.Parent.Equipped:connect(function(mouse)
  376. --print("Internal Equipped: Time b: "..time())
  377. --set up general values in the tool
  378. this.Mouse = mouse
  379. local curOwner = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
  380. if curOwner ~= this.Player then
  381. this.Player = curOwner
  382. this.OwnerChange:fire(this.Player)
  383. end
  384. this.Character = this.Player.Character
  385. this.Humanoid = this.Character.Humanoid
  386. this.AnimationProvider:setHumanoid(this.Humanoid)
  387.  
  388. --set up the mouse events
  389. mouse.Button1Down:connect(function()
  390. this.MouseDown = true
  391. local t = tick()
  392. if (t-mLastClickTime) < this.DoubleClickThreshold then
  393. --prvent multiple double-clicks in a row
  394. mLastClickTime = 0
  395. this.MouseDoubleClick:fire(mouse)
  396. else
  397. mLastClickTime = t
  398. this.MouseClick:fire(mouse)
  399. end
  400. end)
  401. mouse.Button1Up:connect(function()
  402. this.MouseDown = false
  403. if EmitterPart then
  404. EmitterPart:Destroy()
  405. EmitterPart=nil
  406. end
  407. end)
  408. mouse.KeyDown:connect(function(key)
  409. this.KeyDown:fire(key)
  410. end)
  411.  
  412. --done setup, call the equipped function
  413. if this.HUGE_EQUIP_HACK then
  414. --the HUGE_EQUIP_HACK flags tells the tool that the equip is a synchronous
  415. --call as a result of parenting an animation to the character, which happens
  416. --when the tool is picked up from the workspace, but not during normal equips
  417. --(Why does this happen???), if this is the case, the call should be rederrred
  418. --one tick to ensure that all of the gear's loading can complete before it's
  419. --equipped event is called.
  420. --TODO: Blame John for this.
  421. Delay(0, function()
  422. this.Equipped:fire(mouse)
  423. end)
  424. else
  425. --otherwise, proceed as normal
  426. this.Equipped:fire(mouse)
  427. end
  428. end)
  429.  
  430. script.Parent.Unequipped:connect(function()
  431. --before my teardown, fire the event
  432. this.Unequipped:fire()
  433.  
  434. --delete all my garbage
  435. this.Bin:cleanAll()
  436. end)
  437. end)
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462. local BeamColor = BrickColor.new(Color3.new(255, 0, 0))
  463. local PartModel = Create'Model'{
  464. Name = 'SpotWeld_Parts',
  465. }
  466. local Failsafe = nil
  467.  
  468. Tool.AnimationProvider:registerAnimation('equip', 'http://www.roblox.com/asset/?id=69427262')
  469. Tool.AnimationProvider:registerAnimation('fire', 'http://www.roblox.com/asset/?id=69427271')
  470. Tool.AnimationProvider:registerAnimation('hold', 'http://www.roblox.com/asset/?id=69427277')
  471.  
  472. class'RaycastIgnore'(nil, function(def)
  473. local mIgnoreMap = setmetatable({}, {__mode='k'})
  474. function def:addIgnore(obj)
  475. mIgnoreMap[obj] = true
  476. end
  477. function def:genIgnoreList()
  478. local ignoreList = {}
  479. for p, _ in pairs(mIgnoreMap) do
  480. ignoreList[#ignoreList+1] = p
  481. for _,t in pairs(p:GetChildren()) do
  482. if t.Name == 'Effect' then
  483. ignoreList[#ignoreList+1] = t
  484. end
  485. end
  486. end
  487. for _, ch in pairs(Tool.Character:GetChildren()) do
  488. if ch:IsA('BasePart') then
  489. ignoreList[#ignoreList+1] = ch
  490. end
  491. for _, handle in pairs(ch:GetChildren()) do
  492. if handle:IsA('BasePart') then
  493. ignoreList[#ignoreList+1] = ch
  494. end
  495. end
  496. end
  497. return ignoreList
  498. end
  499. end)
  500.  
  501. class'SpotWeld_Charge'(function(this)
  502. this.Completed = CreateSignal()
  503. --
  504. local mReady = false
  505. local mSpokeList = {} --[i] = {Direction, Part, Len, Dist}
  506. local mChargeSphere = nil
  507. local mFracComplete = 0
  508. --
  509. local mLocation;
  510. --
  511. local mCurrentRun = 0
  512. --
  513. local function genSpokes()
  514. if mReady then return end
  515. mReady = true
  516.  
  517. --make charge sphere
  518. mChargeSphere = Create'Part'{
  519. Name = 'SpotWeld_ChrageSphere',
  520. FormFactor = 'Custom',
  521. Anchored = true,
  522. CanCollide = false,
  523. Transparency = 0.3,
  524. BrickColor = BeamColor,
  525. Create'SpecialMesh'{MeshType='Sphere',},
  526. }
  527. RaycastIgnore:addIgnore(mChargeSphere)
  528.  
  529. --make new spokes
  530. for i = 1, 20 do
  531. local spoke = {}
  532. spoke.Part = Create'Part'{
  533. Name = 'SpotWeld_Spoke',
  534. FormFactor = 'Custom',
  535. Anchored = true,
  536. CanCollide = false,
  537. Transparency = 0.3,
  538. BrickColor = BeamColor,
  539. }
  540. RaycastIgnore:addIgnore(spoke.Part)
  541. mSpokeList[i] = spoke
  542. end
  543. end
  544. local function randomizeSpokes()
  545. for _, spoke in pairs(mSpokeList) do
  546. spoke.Direction = CFrame.new(mLocation)*CFrame.Angles(math.random(-1.14, 1.14),
  547. math.random(-1.14, 1.14),
  548. math.random(-1.14, 1.14))
  549. spoke.Len = math.random()*1+1
  550. spoke.Dist = math.random()*1+1
  551. spoke.Part.Size = Vector3.new(0.1, 0.1, spoke.Len)
  552. end
  553. end
  554. local function showSpokes(state)
  555. if mReady then
  556. local par = ((state) and PartModel or nil)
  557. mChargeSphere.Parent = par
  558. for _, spoke in pairs(mSpokeList) do
  559. spoke.Part.Parent = par
  560. end
  561. end
  562. end
  563. local function setSpokes()
  564. local sphereSz = mFracComplete
  565. mChargeSphere.Size = Vector3.new(sphereSz, sphereSz, sphereSz)
  566. mChargeSphere.CFrame = CFrame.new(mLocation)
  567. --
  568. for _, spoke in pairs(mSpokeList) do
  569. local endDistOut = (1-mFracComplete)*spoke.Dist
  570. local innerDistOut = endDistOut-spoke.Len-sphereSz
  571. local gotLen;
  572. if innerDistOut < 0 then
  573. gotLen = spoke.Len+innerDistOut
  574. else
  575. gotLen = spoke.Len
  576. end
  577. spoke.Part.Size = Vector3.new(0.1, 0.1, spoke.Len+innerDistOut)
  578. spoke.Part.CFrame = spoke.Direction*CFrame.new(0, 0, -(endDistOut-gotLen/2))
  579. end
  580. end
  581. --
  582. function this:run(location)
  583. mLocation = location
  584. mCurrentRun = mCurrentRun+1
  585. local thisRun = mCurrentRun
  586. mFracComplete = 0
  587. --
  588. genSpokes()
  589. randomizeSpokes()
  590. showSpokes(true)
  591. --
  592. Spawn(function()
  593. local lastTime = tick()
  594. while mCurrentRun == thisRun and mFracComplete < 1 do
  595. local now = tick()
  596. local dt = now-lastTime
  597. lastTime = now
  598. --
  599. mFracComplete = math.min(1, mFracComplete+dt*2)
  600. setSpokes()
  601. --
  602. wait()
  603. end
  604. if mCurrentRun == thisRun then
  605. showSpokes(false)
  606. this.Completed:fire()
  607. end
  608. end)
  609. end
  610. function this:stop()
  611. showSpokes(false)
  612. mCurrentRun = mCurrentRun+1
  613. end
  614. --
  615. function this:destroy()
  616. mReady = false
  617. mChargeSphere:Destroy()
  618. for i, spoke in pairs(mSpokeList) do
  619. mSpokeList[i] = nil
  620. spoke.Part:Destroy()
  621. end
  622. end
  623. end)
  624.  
  625.  
  626.  
  627. --[[
  628. locations:
  629.  
  630. C
  631. /\
  632. / \
  633. A B
  634. locationGetFunc => A, B, C
  635. ]]
  636. local function frand(a, b)
  637. return a+math.random()*(b-a)
  638. end
  639. class'WavyBeam'(function(this, numSegs)
  640. local mSegList = {}
  641. for i = 1, numSegs do
  642. mSegList[i] = Create'Part'{
  643. Name = 'SpotWeld_BeamBit',
  644. Anchored = true,
  645. CanCollide = false,
  646. FormFactor = 'Custom',
  647. BrickColor = BeamColor,
  648. Transparency = 0.3,
  649. }
  650. RaycastIgnore:addIgnore(mSegList[i])
  651. end
  652. function this:show(from, to)
  653. local totalLen = (from-to).magnitude
  654. local wave = math.min(totalLen/5, 1)/2
  655. local dirCF = CFrame.new(from, to)
  656. local lastPos = dirCF.p --(dirCF*CFrame.new(frand(-wave, wave), frand(-wave, wave), 0)).p
  657. for i = 1, numSegs do
  658. local p = mSegList[i]
  659. p.Parent = PartModel
  660. local distToThisEnd = i*(totalLen/numSegs)
  661. local newPos;
  662. if i == numSegs then
  663. newPos = (dirCF*CFrame.new(0,0,-distToThisEnd)).p
  664. else
  665. newPos = (dirCF*CFrame.new(frand(-wave, wave),
  666. frand(-wave, wave),
  667. -distToThisEnd)).p
  668. end
  669. p.Size = Vector3.new(0.1, 0.1, totalLen/numSegs)
  670. p.CFrame = CFrame.new(lastPos, newPos)*CFrame.new(0, 0, -(lastPos-newPos).magnitude/2)
  671. lastPos = newPos
  672. end
  673. end
  674. function this:hide()
  675. for i = 1, numSegs do
  676. mSegList[i].Parent = nil
  677. end
  678. end
  679. end)
  680. class'SpotWeld_Beam'(function(this)
  681.  
  682.  
  683. local mParticleEmitter = Create'Part'{
  684. Name = 'SpotWeld_ParticleEmitter',
  685. Anchored = true,
  686. CanCollide = false,
  687. Transparency = 1,
  688. Create'Sound'{
  689. Name = 'HoldSound1',
  690. Looped = true,
  691. SoundId = 'http://www.roblox.com/asset/?id=100429993',
  692. Volume=1
  693. },
  694. Create'Sound'{
  695. Name = 'HoldSound2',
  696. Looped = true,
  697. SoundId = 'http://www.roblox.com/asset/?id=100429993',
  698. Volume=1
  699. },
  700. }
  701. RaycastIgnore:addIgnore(mParticleEmitter)
  702. local mBeam_AC = CreateWavyBeam(2)
  703. local mBeam_BC = CreateWavyBeam(2)
  704. --
  705. local mIsShown = false
  706. function this:show(a, b, c, showBeam)
  707. if not a then
  708. this:hide()
  709. return
  710. end
  711.  
  712. --
  713. mBeam_AC:show(a, c)
  714. mBeam_BC:show(b, c)
  715. --
  716.  
  717. --
  718. if showBeam then
  719. --
  720. mParticleEmitter.Parent = PartModel
  721. mParticleEmitter.CFrame = CFrame.new(c)
  722. --
  723. if not mIsShown then
  724. mParticleEmitter.HoldSound1:Play()
  725. Delay(0.5, function() mParticleEmitter.HoldSound2:Play() end)
  726. end
  727. mIsShown = true
  728. else
  729. if EmitterPart then
  730. EmitterPart:Destroy()
  731. EmitterPart=nil
  732. end
  733. mParticleEmitter.Parent = nil
  734. mIsShown = false
  735. end
  736. --
  737. end
  738. function this:hide()
  739. mIsShown = false
  740. --
  741. mBeam_AC:hide()
  742. mBeam_BC:hide()
  743. --
  744. mParticleEmitter.Parent = nil
  745. end
  746. end)
  747.  
  748. --effects
  749. local ChargeEffect = CreateSpotWeld_Charge()
  750. local BeamEffect = CreateSpotWeld_Beam()
  751.  
  752. --helper to show the beam
  753. function showBeamEffect(target, showBeam)
  754. local ch = Tool.Character
  755. local head = ch:FindFirstChild("Head")
  756. if not (head) then
  757. BeamEffect:hide()
  758. end
  759. --
  760. local ray = CFrame.new(head.Position, target)*CFrame.new(0, 2, -1)
  761. local a = (head.CFrame*CFrame.new(-.25, 0, 0)).p
  762. local b = (head.CFrame*CFrame.new(.25, 0, 0)).p
  763. local c = target
  764. --
  765. --local b = (head.CFrame*CFrame.new(-0.3, 0.15, -0.6)).p
  766. BeamEffect:show(a, b, c, showBeam)
  767. end
  768.  
  769.  
  770. function findFaceFromCoord(size, loc)
  771. local pa, pb = -size/2, size/2
  772. local dx = math.min(math.abs(loc.x-pa.x), math.abs(loc.x-pb.x))
  773. local dy = math.min(math.abs(loc.y-pa.y), math.abs(loc.y-pb.y))
  774. local dz = math.min(math.abs(loc.z-pa.z), math.abs(loc.z-pb.z))
  775. --
  776. if dx < dy and dx < dz then
  777. if math.abs(loc.x-pa.x) < math.abs(loc.x-pb.x) then
  778. return Enum.NormalId.Left --'Left'
  779. else
  780. return Enum.NormalId.Right --'Right'
  781. end
  782. elseif dy < dx and dy < dz then
  783. if math.abs(loc.y-pa.y) < math.abs(loc.y-pb.y) then
  784. return Enum.NormalId.Bottom --'Bottom'
  785. else
  786. return Enum.NormalId.Top --'Top'
  787. end
  788. elseif dz < dx and dz < dy then
  789. if math.abs(loc.z-pa.z) < math.abs(loc.z-pb.z) then
  790. return Enum.NormalId.Front --'Front'
  791. else
  792. return Enum.NormalId.Back --'Back'
  793. end
  794. end
  795. end
  796.  
  797.  
  798.  
  799. function createFire(part, hit)
  800. if (part.Parent or game):FindFirstChild("Humanoid") or
  801. ((part.Parent or game).Parent or game):FindFirstChild("Humanoid") then
  802. return
  803. end
  804. if not EmitterPart then
  805. EmitterPart = Create'Part'{
  806. Name = 'EmitPart',
  807. FormFactor = 'Custom',
  808. CanCollide = false,
  809. Anchored = true,
  810. Size = Vector3.new(.2, .2, .2),
  811. Transparency = 1,
  812. Parent = script.Parent,
  813. }
  814. RaycastIgnore:addIgnore(EmitterPart)
  815. local emitScript = script:FindFirstChild('Emitter'):Clone()
  816. emitScript.Parent=EmitterPart
  817. emitScript.Disabled = false
  818. end
  819.  
  820.  
  821. local hitFace = findFaceFromCoord(part.Size, part.CFrame:toObjectSpace(CFrame.new(hit)))
  822. local dir = (part.CFrame-part.Position)*Vector3.FromNormalId(hitFace)
  823. if part:IsA('Terrain') then
  824. EmitterPart.CFrame = CFrame.new(hit)
  825. else
  826. EmitterPart.CFrame = CFrame.new(hit, hit+dir)*CFrame.Angles(-math.pi/2, 0, 0)
  827. end
  828. game.Debris:AddItem(scorch, 5)
  829. end
  830.  
  831.  
  832. local mClickNum = 0
  833. local mSelected = false
  834. Tool.MouseClick:connect(function()
  835. mClickNum = mClickNum+1
  836. local thisClick = mClickNum
  837. if not Tool.Mouse.Target or not Tool.Character:FindFirstChild("Head") then
  838. return
  839. end
  840. --
  841. Tool.AnimationProvider:getAnimation('fire'):Play(0, 1, 4)
  842. Spawn(function()
  843. repeat until Tool.AnimationProvider:getAnimation('fire').KeyframeReached:wait() == 'complete'
  844. Tool.AnimationProvider:getAnimation('hold'):Play(0, 1, 1)
  845. end)
  846. --
  847. Tool.Humanoid.WalkSpeed = 0
  848. --
  849. local headPos = Tool.Character.Head.Position
  850. local hit = Tool.Mouse.Hit.p
  851. ChargeEffect:run((CFrame.new(headPos, hit)*CFrame.new(0, 2, -3)).p)
  852. ChargeEffect.Completed:wait()
  853. ChargeEffect:stop()
  854. --
  855. local isDamageTick = false
  856. local timeOfLastScorch = tick()
  857. local partsToIgnore = RaycastIgnore:genIgnoreList()
  858. local headPart = Tool.Character:FindFirstChild("Head")
  859. while mSelected and Tool.MouseDown and mClickNum == thisClick and headPart do
  860. --first, find the true mouse hit, ignoring my ray parts
  861. local mouseRay = Tool.Mouse.UnitRay
  862. local newRay = Ray.new(mouseRay.Origin, mouseRay.Direction.unit*999.9)
  863. local _, hit = game.Workspace:FindPartOnRayWithIgnoreList(newRay, partsToIgnore)
  864.  
  865. --found true hit, now go on to raycast to there from firefrom point
  866. local headPos = Tool.Character.Head.Position
  867. local fireFrom = (CFrame.new(headPos, hit)*CFrame.new(0, 2, -1)).p
  868. local castRay = Ray.new(fireFrom, (hit-fireFrom).unit*999.9)
  869. local part, target = game.Workspace:FindPartOnRayWithIgnoreList(castRay, partsToIgnore)
  870.  
  871. local charHeading = Tool.Character.Torso.CFrame.lookVector
  872. local outOfFOV = (math.acos((target-fireFrom).unit:Dot(charHeading)) > 1.5)
  873. if not target or outOfFOV then
  874. --just shoot arbitrarily ahead
  875. showBeamEffect((Tool.Character.Head.CFrame*CFrame.new(0, 0, -10)).p, false)
  876.  
  877. elseif (target-fireFrom).magnitude > 50 then
  878. --too far away
  879. target = fireFrom+(target-fireFrom).unit*50
  880. showBeamEffect(target, false)
  881.  
  882. else
  883. --mechanism to do more damage every other tick
  884. isDamageTick = not isDamageTick
  885. if isDamageTick then
  886. --see if the target exists and is a humanoid
  887. local hum = (part.Parent or game):FindFirstChild("Humanoid")
  888. hum = hum or ((part.Parent or game).Parent or game):FindFirstChild("Humanoid")
  889. if hum then
  890. --found a humanoid, do damage
  891. TagHumanoid(hum)
  892. hum:TakeDamage(4)
  893. end
  894. end
  895.  
  896. --make scorch effects
  897. if (tick()-timeOfLastScorch) > 0.1 then
  898. timeOfLastScorch = tick()
  899. createFire(part, target)
  900. end
  901.  
  902. --show the beam
  903. showBeamEffect(target, true)
  904. end
  905. wait()
  906. end
  907. if mClickNum == thisClick then
  908. BeamEffect:hide()
  909. Tool.Humanoid.WalkSpeed = 16
  910. Tool.AnimationProvider:getAnimation('hold'):Stop()
  911. end
  912. end)
  913.  
  914. local mHatPart = nil
  915. Tool.Equipped:connect(function()
  916. mSelected = true
  917. PartModel.Parent = game.Workspace
  918. Failsafe = Tool.Tool.Failsafe:Clone()
  919. Failsafe.Disabled = false
  920. Failsafe.Model.Value = PartModel
  921. Failsafe.Humanoid.Value = Tool.Humanoid
  922. Failsafe.Parent = PartModel
  923. --
  924. Tool.AnimationProvider:getAnimation('equip'):Play(0.1, 1, 4)
  925. --Tool.Tool.Grip = CFrame.new()
  926. Tool.Tool.Handle.Transparency = 1
  927. --
  928. Spawn(function()
  929. --this code causes re-firing of the equipped event fpor some reason?
  930. --putting it in a new thread fixes this behavior
  931. mHatPart = Tool.Tool.Handle:Clone()
  932. mHatPart.Transparency = 0
  933. mHatPart.Parent = Tool.Character
  934. local w = Create'Weld'{
  935. Parent = mHatPart,
  936. Part0 = mHatPart,
  937. Part1 = Tool.Character:FindFirstChild('Head'),
  938. C0 = CFrame.new(0.040000014, 0, 0.0199999996, 1, 0, 0, 0, 1.31134158e-007, 1, 0, -1, 1.31134158e-007),
  939. C1 = CFrame.new(0, 0.200000003, -0.100000001, 1, 0, 0, 0, -4.37113883e-008, 1, 0, -1, -4.37113883e-008)
  940. }
  941. end)
  942. end)
  943.  
  944. Tool.Unequipped:connect(function()
  945. mSelected = false
  946. PartModel.Parent = nil
  947. Failsafe:Destroy()
  948. Failsafe = nil
  949.  
  950. if EmitterPart then
  951. EmitterPart:Destroy()
  952. EmitterPart=nil
  953. end
  954. --
  955. Tool.AnimationProvider:getAnimation('equip'):Stop()
  956. Tool.AnimationProvider:getAnimation('fire'):Stop()
  957. Tool.AnimationProvider:getAnimation('hold'):Stop()
  958. --kill any running effects
  959. ChargeEffect:stop()
  960. BeamEffect:hide()
  961. --
  962. Tool.Humanoid.WalkSpeed = 16
  963. --Tool.Handle.Transparency = 0
  964. --
  965. if mHatPart then
  966. mHatPart:Destroy()
  967. mHatPart = nil
  968. end
  969. end)
  970.  
  971. end))
  972. Script2.Name = "Emitter"
  973. Script2.Parent = LocalScript1
  974. Script2.Disabled = true
  975. table.insert(cors,sandbox(Script2,function()
  976. local Particle = Instance.new('Part')
  977. Particle.Name = 'Effect'
  978. Particle.Size = Vector3.new(.2,.2,.2)
  979. Particle.CanCollide = false
  980. Particle.Transparency = 1
  981. local PartMesh = Instance.new('SpecialMesh')
  982. PartMesh.Name = 'PartMesh'
  983. PartMesh.MeshId = 'http://www.roblox.com/asset/?id=87112830'--'http://www.roblox.com/asset/?id=96501868'--
  984. PartMesh.TextureId = 'http://www.roblox.com/asset/?id=99871304'
  985. PartMesh.Parent=Particle
  986. local PartVelocity = Instance.new('BodyVelocity')
  987. PartVelocity.maxForce = Vector3.new(99999999,99999999,999999)
  988. PartVelocity.velocity= Vector3.new(0,1,0)
  989. PartVelocity.Parent=Particle
  990. local PartSpin = Instance.new('BodyAngularVelocity')
  991. PartSpin.maxTorque = Vector3.new(999999999,99999999,999999)
  992. PartSpin.angularvelocity =Vector3.new(1,1,1)
  993. PartSpin.Parent=Particle
  994.  
  995. local Lifetime = 2
  996. local Rate =.1
  997.  
  998. function TweenTransparency(element,starta,enda,length)
  999. local startTime = time()
  1000. while time() - startTime < length do
  1001. element.Transparency = ((enda - starta) * ((time() - startTime)/length)) + starta
  1002. wait(.01)
  1003. end
  1004. element.Transparency = enda
  1005. end
  1006.  
  1007. function TweenScale(element,starts,ends,length)
  1008. local startTime = time()
  1009. while time() - startTime < length do
  1010. element.Scale = ((ends - starts) * ((time() - startTime)/length)) + starts
  1011. wait(.01)
  1012. end
  1013. element.Scale = ends
  1014. end
  1015.  
  1016. function TweenColor(element,startc,endc,length)
  1017. local startTime = time()
  1018. while time() - startTime < length do
  1019. element.VertexColor = ((endc - startc) * ((time() - startTime)/length)) + startc
  1020. wait(.01)
  1021. end
  1022. element.VertexColor = endc
  1023. end
  1024.  
  1025. while true do
  1026. PartVelocity.velocity= Vector3.new((math.random()-.5)/2,math.random()+3,(math.random()-.5)/2)
  1027. PartMesh.Scale= Vector3.new((math.random()/2)+.2,math.random()/2+.2,math.random()/2+.2)
  1028. PartSpin.angularvelocity =Vector3.new(math.random()*3,math.random()*3,math.random()*3)
  1029. Particle.CFrame= script.Parent.CFrame
  1030. local npart= Particle:Clone()
  1031. local nmesh = npart:FindFirstChild('PartMesh')
  1032. npart.Transparency = 1
  1033. npart.Parent=script.Parent
  1034.  
  1035. Spawn(function()
  1036. TweenTransparency(npart, 1,.5,.1)
  1037. TweenTransparency(npart, .5,1,1.5)
  1038. end)
  1039. --Spawn(function()
  1040. --TweenColor(nmesh, Vector3.new(.8+(math.random()*.4),1,1),Vector3.new(.5,.5,.5),1.5)
  1041. --end)
  1042. Spawn(function() TweenScale(nmesh,nmesh.Scale,nmesh.Scale*math.random()*.5,1.5) end)
  1043. game.Debris:AddItem(npart,Lifetime)
  1044. wait(Rate)
  1045.  
  1046. end
  1047. end))
  1048. Part3.Name = "Handle"
  1049. Part3.Parent = Tool0
  1050. Part3.FormFactor = Enum.FormFactor.Symmetric
  1051. Part3.Shape = Enum.PartType.Ball
  1052. Part3.Size = Vector3.new(1, 1, 1)
  1053. Part3.CFrame = CFrame.new(80.6800003, 19.2970848, 174.050003, 1, -2.21533113e-17, 9.25474816e-17, 2.21533113e-17, 1, -3.76204621e-17, -9.25474816e-17, 3.76204621e-17, 1)
  1054. Part3.BottomSurface = Enum.SurfaceType.Smooth
  1055. Part3.TopSurface = Enum.SurfaceType.Smooth
  1056. Part3.Position = Vector3.new(80.6800003, 19.2970848, 174.050003)
  1057. SpecialMesh4.Parent = Part3
  1058. SpecialMesh4.MeshId = "http://www.roblox.com/asset/?id=1185246"
  1059. SpecialMesh4.Scale = Vector3.new(4, 4, 4)
  1060. SpecialMesh4.TextureId = "http://www.roblox.com/asset/?id=5013397"
  1061. SpecialMesh4.MeshType = Enum.MeshType.FileMesh
  1062. SpecialMesh4.Scale = Vector3.new(4, 4, 4)
  1063. Script5.Name = "Failsafe"
  1064. Script5.Parent = Tool0
  1065. Script5.Disabled = true
  1066. table.insert(cors,sandbox(Script5,function()
  1067. while not script:FindFirstChild("Humanoid") do
  1068. script.ChildAdded:wait()
  1069. end
  1070. script.Humanoid.Value.Died:connect(function()
  1071. script.Model.Value:Destroy()
  1072. end)
  1073. end))
  1074. ObjectValue6.Name = "Model"
  1075. ObjectValue6.Parent = Script5
  1076. ObjectValue7.Name = "Humanoid"
  1077. ObjectValue7.Parent = Script5
  1078. for i,v in pairs(mas:GetChildren()) do
  1079. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  1080. pcall(function() v:MakeJoints() end)
  1081. end
  1082. mas:Destroy()
  1083. for i,v in pairs(cors) do
  1084. spawn(function()
  1085. pcall(v)
  1086. end)
  1087. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement