Advertisement
Godofadmin1337

The sun is a dedly lazer

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