gecksad

Untitled

Dec 25th, 2018
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --]]
  2. --https://github.com/Mokiros/roblox-FE-compatibility
  3. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  4. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  5. local RealPlayer = Player
  6. do print("FE Compatibility code by Mokiros")local a=RealPlayer;script.Parent=a.Character;local b=Instance.new("RemoteEvent")b.Name="UserInput_Event"local function c()local d={_fakeEvent=true,Functions={},Connect=function(self,e)table.insert(self.Functions,e)end}d.connect=d.Connect;return d end;local f={Target=nil,Hit=CFrame.new(),KeyUp=c(),KeyDown=c(),Button1Up=c(),Button1Down=c(),Button2Up=c(),Button2Down=c()}local g={InputBegan=c(),InputEnded=c()}local CAS={Actions={},BindAction=function(self,h,i,j,...)CAS.Actions[h]=i and{Name=h,Function=i,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function k(self,l,...)local d=f[l]if d and d._fakeEvent then for m,e in pairs(d.Functions)do e(...)end end end;f.TrigEvent=k;g.TrigEvent=k;b.OnServerEvent:Connect(function(n,o)if n~=a then return end;f.Target=o.Target;f.Hit=o.Hit;if not o.isMouse then local p=o.UserInputState==Enum.UserInputState.Begin;if o.UserInputType==Enum.UserInputType.MouseButton1 then return f:TrigEvent(p and"Button1Down"or"Button1Up")end;if o.UserInputType==Enum.UserInputType.MouseButton2 then return f:TrigEvent(p and"Button2Down"or"Button2Up")end;for m,d in pairs(CAS.Actions)do for m,q in pairs(d.Keys)do if q==o.KeyCode then d.Function(d.Name,o.UserInputState,o)end end end;f:TrigEvent(p and"KeyDown"or"KeyUp",o.KeyCode.Name:lower())g:TrigEvent(p and"InputBegan"or"InputEnded",o,false)end end)b.Parent=NLS([==[local a=game:GetService("Players").LocalPlayer;local b=script:WaitForChild("UserInput_Event")local c=a:GetMouse()local d=game:GetService("UserInputService")local e=function(f,g)if g then return end;b:FireServer({KeyCode=f.KeyCode,UserInputType=f.UserInputType,UserInputState=f.UserInputState,Hit=c.Hit,Target=c.Target})end;d.InputBegan:Connect(e)d.InputEnded:Connect(e)local h,i;while wait(1/30)do if h~=c.Hit or i~=c.Target then h,i=c.Hit,c.Target;b:FireServer({isMouse=true,Target=i,Hit=h})end end]==],Player.Character)local r=game;local s={__index=function(self,q)local t=rawget(self,"_RealService")if t then return typeof(t[q])=="function"and function(m,...)return t[q](t,...)end or t[q]end end,__newindex=function(self,q,u)local t=rawget(self,"_RealService")if t then t[q]=u end end}local function v(d,w)d._RealService=typeof(w)=="string"and r:GetService(w)or w;return setmetatable(d,s)end;local x={GetService=function(self,t)return rawget(self,t)or r:GetService(t)end,Players=v({LocalPlayer=v({GetMouse=function(self)return f end},Player)},"Players"),UserInputService=v(g,"UserInputService"),ContextActionService=v(CAS,"ContextActionService"),RunService=v({_btrs={},RenderStepped=r:GetService("RunService").Heartbeat,BindToRenderStep=function(self,h,m,i)self._btrs[h]=self.Heartbeat:Connect(i)end,UnbindFromRenderStep=function(self,h)self._btrs[h]:Disconnect()end},"RunService")}rawset(x.Players,"localPlayer",x.Players.LocalPlayer)x.service=x.GetService;v(x,game)game,owner=x,x.Players.LocalPlayer end
  7.  
  8. local Player = game.Players.LocalPlayer
  9. local Mouse = Player:GetMouse()
  10. repeat wait() until Player.Character
  11. local Character = Player.Character
  12.  
  13. local scriptId = "GhostScriptID-9211"
  14. script.Name = scriptId
  15. script.Parent = Player.PlayerScripts
  16.  
  17. local GhostObject
  18. local SwordObject
  19.  
  20. -- | Functions
  21.  
  22. -- General
  23.  
  24. local General = {}
  25.  
  26. function General.LoopClosure(parent, func)
  27. for _,v in pairs(parent:GetChildren()) do
  28. func(v)
  29. end
  30. end
  31.  
  32. function General.IsMainBodyPart(part)
  33. if part:IsA("Part") and part.Name ~= "HumanoidRootPart" and part.Name ~= "Head" then
  34. return true
  35. else
  36. return false
  37. end
  38. end
  39.  
  40. function General.TweenTransparency(model, start, finish)
  41. local value = start
  42.  
  43. if start < finish then
  44. repeat
  45. value = value + 0.1
  46. General.LoopClosure(model, function(v)
  47. if General.IsMainBodyPart(v) then
  48. v.Transparency = value
  49. end
  50. end)
  51. wait()
  52. until value >= finish
  53. else
  54. repeat
  55. value = value - 0.1
  56. General.LoopClosure(model, function(v)
  57. if General.IsMainBodyPart(v) then
  58. v.Transparency = value
  59. end
  60. end)
  61. wait()
  62. until value <= finish
  63. end
  64. end
  65.  
  66. function General.TweenSize(part, start, finish, increment, waitTime)
  67. local value = start
  68.  
  69. if start < finish then
  70. repeat
  71. value = value + increment
  72. part.Size = part.Size + Vector3.new(increment, increment, increment)
  73. wait(waitTime)
  74. until value >= finish
  75. else
  76. repeat
  77. value = value - increment
  78. part.Size = part.Size - Vector3.new(increment, increment, increment)
  79. wait(waitTime)
  80. until value <= finish
  81. end
  82. end
  83.  
  84. function General.TweenSizeCo(part, start, finish, increment, waitTime, tweenFunction, finishedFunction)
  85. coroutine.resume(coroutine.create(function()
  86. local value = start
  87.  
  88. if start < finish then
  89. repeat
  90. if part == nil then break end
  91. value = value + increment
  92. part.Size = part.Size + Vector3.new(increment, increment, increment)
  93.  
  94. if tweenFunction ~= nil then tweenFunction() end
  95.  
  96. wait(waitTime)
  97. until value >= finish
  98. else
  99. repeat
  100. if part == nil then break end
  101.  
  102. value = value - increment
  103. part.Size = part.Size - Vector3.new(increment, increment, increment)
  104.  
  105. if tweenFunction ~= nil then tweenFunction() end
  106.  
  107. wait(waitTime)
  108. until value <= finish
  109. end
  110.  
  111. if finishedFunction ~= nil then
  112. finishedFunction()
  113. end
  114. end))
  115. end
  116.  
  117. function General.IsCharacter(part)
  118. if part == nil then return end
  119. if part:FindFirstChild("Humanoid") or part.Parent:FindFirstChild("Humanoid") or part.Parent.Parent:FindFirstChild("Humanoid") then
  120. return true
  121. else
  122. return false
  123. end
  124. end
  125.  
  126. function General.GetCharacter(part)
  127. if part == nil then return end
  128. if part.Parent:FindFirstChild("Humanoid") then
  129. return part.Parent
  130. elseif part.Parent.Parent:FindFirstChild("Humanoid") then
  131. return part.Parent.Parent
  132. end
  133. end
  134.  
  135. function General.GetPlayer(part)
  136. local character = General.GetCharacter(part)
  137.  
  138. if character ~= nil then
  139. local player = game.Players:GetPlayerFromCharacter(character)
  140. if player ~= nil then
  141. return player
  142. end
  143. end
  144. end
  145.  
  146. function General.Weld(part1, part2)
  147. local weld = Instance.new("Weld", part1)
  148. weld.Part0 = part1
  149. weld.Part1 = part2
  150. return weld
  151. end
  152.  
  153. -- Animations
  154.  
  155. -- RIGHT ARM ANGLES | C0 ( +FORWARD/-BACK, +TILT LEFT/-TILT RIGHT, +OUT/-IN ) | C1 INVERSE
  156.  
  157. local Animation = {}
  158. Animation.rigged = false
  159.  
  160. function Animation.RigCharacter(character)
  161.  
  162. local rightArmWeld
  163.  
  164. if not character.Torso:FindFirstChild("RightArmWeld") then
  165. rightArmWeld = General.Weld(character.Torso, character["Right Arm"])
  166. rightArmWeld.Name = "RightArmWeld"
  167. rightArmWeld.C1 = rightArmWeld.C1 * CFrame.new(-1.5, 0, 0)
  168. else
  169. rightArmWeld = character.Torso.RightArmWeld
  170. end
  171.  
  172. Animation.Root = character.HumanoidRootPart:WaitForChild("RootJoint")
  173. Animation.RootRoot = {Animation.Root.C0, Animation.Root.C1} -- the name......
  174. Animation.RightArm = rightArmWeld
  175. Animation.RightArmRoot = {rightArmWeld.C0, rightArmWeld.C1}
  176.  
  177. Animation.rigged = true
  178. end
  179.  
  180. function Animation.Reset()
  181. if not Animation.rigged then return end
  182.  
  183. Animation.Root.C0 = Animation.RootRoot[1]
  184. Animation.Root.C1 = Animation.RootRoot[2]
  185. Animation.RightArm.C0 = Animation.RightArmRoot[1]
  186. Animation.RightArm.C1 = Animation.RightArmRoot[2]
  187. end
  188.  
  189. function Animation.Destroy()
  190. Animation.RightArm:Destroy()
  191. Animation.rigged = false
  192. end
  193.  
  194. -- | Classes
  195.  
  196. -- Custom tool class
  197.  
  198. local Toolv2 = {}
  199.  
  200. Toolv2.create = function()
  201. local instance = {}
  202. instance.enabled = true
  203. instance.active = false
  204. instance.initialized = false
  205.  
  206. instance.postInit = function()
  207. -- override
  208. end
  209.  
  210. instance.init = function(player, char, mouse)
  211. instance.Player = player
  212. instance.Character = char
  213. instance.Mouse = mouse
  214. instance.initialized = true
  215. instance.postInit()
  216. end
  217.  
  218. instance.isReady = function()
  219. if instance.initialized and not instance.active and instance.enabled then
  220. return true
  221. else
  222. return false
  223. end
  224. end
  225.  
  226. return instance
  227. end
  228.  
  229. -- Ghostwalker tool class
  230.  
  231. local Sword = {}
  232.  
  233. Sword.create = function()
  234. local instance = Toolv2.create()
  235.  
  236. instance.postInit = function()
  237. Animation.RigCharacter(instance.Character)
  238. instance.idleStance()
  239. instance.createSword()
  240. instance.lastAttack = game:GetService("RunService").Stepped:wait()
  241. instance.combo = 1
  242. instance.defaultSpeed = 20
  243. instance.night = false
  244.  
  245. instance.Character.Humanoid.WalkSpeed = instance.defaultSpeed
  246. instance.updateSouls(0)
  247.  
  248. instance.Character.Humanoid.Died:connect(function()
  249. instance.enabled = false
  250. end)
  251.  
  252. instance.Mouse.Button1Down:connect(function()
  253. if not instance.isReady() then return end
  254.  
  255. if instance.minion ~= nil then
  256. if instance.minion:FindFirstChild("Humanoid") and Mouse.Hit ~= nil then
  257. instance.minion.Humanoid:MoveTo(Mouse.Hit.p)
  258. end
  259. return
  260. end
  261.  
  262. local t = game:GetService("RunService").Stepped:wait()
  263.  
  264. if t - instance.lastAttack < .5 and instance.combo == 1 then
  265. instance.sliceOut()
  266. instance.combo = 2
  267. elseif t - instance.lastAttack < .5 and instance.combo == 2 then
  268. instance.lunge()
  269. else
  270. instance.sliceInit()
  271. instance.combo = 1
  272. end
  273. end)
  274.  
  275. instance.Mouse.KeyDown:connect(function(key)
  276. if not instance.isReady() then return end
  277.  
  278. key:lower()
  279.  
  280. if key == 'f' then
  281. instance.soulFire()
  282. elseif key == 'e' then
  283. instance.soulControl()
  284. elseif key == 'q' then
  285. instance.soulJail()
  286. elseif key == 'g' then
  287. if instance.night == false then
  288. instance.soulNight()
  289. elseif instance.night == true and Mouse.Hit ~= nil then
  290. instance.genericBlast(Mouse.Hit)
  291. end
  292. elseif key == 't' then
  293. instance.sheathe()
  294. end
  295. end)
  296. end
  297.  
  298. instance.updateSouls = function(amount)
  299. instance.souls = amount
  300. instance.Character.Humanoid.MaxHealth = (instance.souls * 100) + 250
  301. instance.Character.Humanoid.Health = instance.Character.Humanoid.MaxHealth
  302. instance.swordFire.Size = instance.souls
  303. end
  304.  
  305. instance.hitFunction = function(hit, damage)
  306. local char = General.GetCharacter(hit)
  307.  
  308. if char ~= nil and char ~= instance.Character and char.Humanoid.Health > 0 then
  309. if damage == nil then
  310. char.Humanoid.Health = char.Humanoid.Health - ((instance.souls * 10) + 10)
  311. else
  312. char.Humanoid.Health = char.Humanoid.Health - (damage)
  313. end
  314.  
  315. if char.Humanoid.Health <= 0 then
  316. General.TweenTransparency(char, 0, 1)
  317. instance.updateSouls(instance.souls + 1)
  318. end
  319. end
  320. end
  321.  
  322. instance.idleStance = function()
  323. Animation.Reset()
  324. Animation.Root.C1 = Animation.Root.C1 * CFrame.Angles(0, 0, -0.5)
  325. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.Angles(1.5, 0.3, 0.3)
  326. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.new(-0.2, -0.75, -0.2)
  327.  
  328. if instance.swordWeld ~= nil then
  329. instance.swordWeld.C0 = instance.swordWeldRoot[1]
  330. instance.swordWeld.C1 = instance.swordWeldRoot[2]
  331. end
  332. end
  333.  
  334. instance.spellStance = function()
  335. instance.idleStance()
  336.  
  337. for i = 1,10 do
  338. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.Angles(-0.2, 0, 0)
  339. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.new(0, -0.07, 0.05)
  340. instance.createSwordTrail()
  341. wait()
  342. end
  343. end
  344.  
  345. instance.updateAttack = function()
  346. instance.lastAttack = game:GetService("RunService").Stepped:wait()
  347. end
  348.  
  349. instance.createSword = function()
  350. local part = Instance.new("Part", instance.Character)
  351. part.CanCollide = false
  352. part.Transparency = 0.8
  353. part.BrickColor = BrickColor.new("White")
  354. part.Size = Vector3.new(1, 0.8, 4)
  355. part.Material = "Neon"
  356.  
  357. part.Touched:connect(function(hit)
  358. instance.hitFunction(hit, nil)
  359. end)
  360.  
  361. local mesh = Instance.new("SpecialMesh", part)
  362. mesh.MeshType = "FileMesh"
  363. mesh.MeshId = "http://www.roblox.com/asset/?id=12221720"
  364.  
  365. local weld = General.Weld(instance.Character["Right Arm"], part)
  366. weld.C1 = weld.C1 * CFrame.Angles(3.16, 0, 1.6)
  367. weld.C1 = weld.C1 * CFrame.new(0, 1, 1.5)
  368.  
  369. local slashSound = Instance.new("Sound", part)
  370. slashSound.SoundId = "rbxasset://sounds/swordslash.wav"
  371. slashSound.Volume = 0.7
  372.  
  373. instance.sword = part
  374. instance.swordWeld = weld
  375. instance.swordWeldRoot = {weld.C0, weld.C1}
  376. instance.slash = slashSound
  377. instance.swordFire = instance.fireEffect(part, 1, nil)
  378. instance.swordFire.Heat = 1
  379. end
  380.  
  381. instance.createSwordTrail = function()
  382. local part = Instance.new("Part", instance.Character)
  383. part.CanCollide = false
  384. part.Anchored = true
  385. part.Size = Vector3.new(1.3, 0.2, 4)
  386. part.Transparency = 0.9
  387. part.BrickColor = BrickColor.new("White")
  388. part.TopSurface = 0
  389. part.BottomSurface = 0
  390. part.CFrame = instance.sword.CFrame
  391.  
  392. instance.debris(part, 0.2)
  393. end
  394.  
  395. instance.sliceInit = function()
  396. instance.active = true
  397. instance.idleStance()
  398.  
  399. instance.slash:Play()
  400.  
  401. for i = 1,6 do
  402. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.Angles(-0.26, 0, 0)
  403. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.new(0, 0, 0.14)
  404. instance.createSwordTrail()
  405. wait()
  406. end
  407.  
  408. wait(0.2)
  409.  
  410. instance.updateAttack()
  411. instance.idleStance()
  412. instance.active = false
  413. end
  414.  
  415. instance.sliceOut = function()
  416. instance.active = true
  417. instance.idleStance()
  418.  
  419. for i = 1,5 do
  420. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.Angles(0, 0.2, 0)
  421. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.new(-0.14, 0, 0.2)
  422. instance.createSwordTrail()
  423. wait()
  424. end
  425.  
  426. instance.slash:Play()
  427.  
  428. for i = 1,5 do
  429. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.Angles(-0.4, 0, 0)
  430. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.new(0, -0.15, 0.15)
  431. instance.createSwordTrail()
  432. wait()
  433. end
  434.  
  435. wait(0.3)
  436.  
  437. instance.updateAttack()
  438. instance.idleStance()
  439. instance.active = false
  440. end
  441.  
  442. instance.lunge = function()
  443. instance.active = true
  444. instance.idleStance()
  445.  
  446. for i = 1,5 do
  447. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.Angles(-0.4, 0, 0)
  448. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.new(0, -0.15, 0.1)
  449. instance.createSwordTrail()
  450. wait()
  451. end
  452.  
  453. instance.Character.Humanoid.WalkSpeed = 0
  454.  
  455. wait(0.5)
  456.  
  457. instance.swordWeld.C1 = instance.swordWeld.C1 * CFrame.Angles(1.6,0,0)
  458. instance.swordWeld.C1 = instance.swordWeld.C1 * CFrame.new(0, 0.8, 1)
  459.  
  460. instance.positionForce(instance.Character.Torso, (instance.Character.HumanoidRootPart.CFrame * CFrame.new(0, 1, -30)).p, 1.3)
  461. instance.slash:Play()
  462.  
  463. for i = 1,4 do -- added .2 due to 1 less frame
  464. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.Angles(0.5, 0, 0)
  465. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.new(0, 0.17, -0.14)
  466. wait()
  467. end
  468.  
  469. wait(0.4)
  470.  
  471. instance.genericBlast(instance.sword.CFrame)
  472.  
  473. wait(0.6)
  474.  
  475. instance.Character.Humanoid.WalkSpeed = instance.defaultSpeed
  476.  
  477. --instance.updateAttack()
  478. instance.idleStance()
  479. instance.active = false
  480. end
  481.  
  482. instance.startSpell = function(requirement)
  483. if instance.souls < requirement then
  484. return false
  485. else
  486. instance.updateSouls(instance.souls - requirement)
  487. end
  488.  
  489. instance.active = true
  490. instance.Character.Humanoid.WalkSpeed = 0
  491. instance.spellStance()
  492.  
  493. return true
  494. end
  495.  
  496. instance.endSpell = function()
  497. instance.Character.Humanoid.WalkSpeed = instance.defaultSpeed
  498. instance.idleStance()
  499. instance.active = false
  500. end
  501.  
  502. instance.genericBlast = function(cf)
  503. local sound = Instance.new("Sound")
  504. sound.SoundId = "rbxasset://sounds\\HalloweenGhost.wav"
  505. sound.Parent = instance.sword
  506. sound:Play()
  507.  
  508. local spell = instance.spellEffect()
  509. spell.CFrame = cf
  510. spell.Touched:connect(function(hit)
  511. instance.hitFunction(hit, 10)
  512. end)
  513.  
  514. General.TweenSizeCo(spell, spell.Size.X, 24, 1, 0.025, function()
  515. if spell ~= nil then
  516. spell.Transparency = spell.Transparency + 0.025
  517. spell.CFrame = cf
  518. end
  519. end,
  520. function()
  521. if spell ~= nil then
  522. spell:Destroy()
  523. end
  524. end) -- First function fires every time the part size is changed / while part size is tweening. Second function fires once the tweening process is complete.
  525. end
  526.  
  527. instance.soulFire = function()
  528. if not instance.startSpell(1) then return end
  529.  
  530. local sound = Instance.new("Sound")
  531. sound.SoundId = "rbxasset://sounds\\HalloweenGhost.wav"
  532. sound.Parent = instance.sword
  533. sound:Play()
  534.  
  535. local spell = instance.spellEffect()
  536. spell.CFrame = instance.Character.Torso.CFrame
  537. spell.Touched:connect(function(hit)
  538. instance.hitFunction(hit, 100)
  539. end)
  540.  
  541. for i = 1, 20 do
  542. spell.Size = spell.Size + Vector3.new(3, 3, 3)
  543. spell.Transparency = spell.Transparency + 0.025
  544. spell.CFrame = instance.Character.Torso.CFrame
  545. wait()
  546. end
  547.  
  548. spell:Destroy()
  549.  
  550. wait(0.3)
  551.  
  552. instance.endSpell()
  553. end
  554.  
  555. instance.soulControl = function()
  556. if not instance.startSpell(1) then return end
  557.  
  558. local sound = Instance.new("Sound")
  559. sound.SoundId = "rbxasset://sounds\\HalloweenGhost.wav"
  560. sound.Parent = instance.sword
  561. sound:Play()
  562.  
  563. if instance.minion ~= nil then
  564. instance.minion = nil
  565. instance.minionConnection:disconnect()
  566. else
  567. local char = General.GetCharacter(instance.Mouse.Target)
  568. if char ~= nil and char:FindFirstChild("Torso") then
  569. instance.minion = char
  570. instance.minionConnection = char.Torso.Touched:connect(function(hit)
  571. instance.hitFunction(hit, 100)
  572. end)
  573. instance.fireEffect(char.Torso, 4, nil)
  574. end
  575. end
  576.  
  577. wait(0.3)
  578.  
  579. instance.endSpell()
  580. end
  581.  
  582. instance.soulJail = function()
  583. if not instance.startSpell(3) then return end
  584.  
  585. local sound = Instance.new("Sound")
  586. sound.SoundId = "rbxasset://sounds\\HalloweenGhost.wav"
  587. sound.Parent = instance.sword
  588. sound:Play()
  589.  
  590. local char = General.GetCharacter(instance.Mouse.Target)
  591. if char ~= nil and char:FindFirstChild("Torso") then
  592. char.Torso.Anchored = true
  593. char.Humanoid.WalkSpeed = 0
  594.  
  595. local spell = instance.spellEffect()
  596. spell.Size = Vector3.new(12, 12, 12)
  597. spell.CFrame = char.Torso.CFrame
  598.  
  599. instance.debris(spell, 30)
  600. end
  601.  
  602. wait(0.5)
  603.  
  604. instance.endSpell()
  605. end
  606.  
  607. instance.soulNight = function()
  608. if not instance.startSpell(5) then return end
  609.  
  610. instance.night = true
  611.  
  612. local sound = Instance.new("Sound")
  613. sound.SoundId = "rbxasset://sounds\\HalloweenGhost.wav"
  614. sound.Parent = instance.sword
  615. sound:Play()
  616.  
  617. local timeOfDay = 12
  618.  
  619. for i = 1, 12 do
  620. game.Lighting.TimeOfDay = tostring(timeOfDay)
  621. timeOfDay = timeOfDay + 1
  622. wait(0.1)
  623. end
  624.  
  625. instance.fireEffect(instance.Character.Torso, 5, 10)
  626.  
  627. wait(0.5)
  628.  
  629. instance.endSpell()
  630. instance.Character.Humanoid.WalkSpeed = 30
  631. instance.defaultSpeed = 30
  632.  
  633. coroutine.resume(coroutine.create(function()
  634. wait(10)
  635.  
  636. instance.defaultSpeed = 20
  637.  
  638. if instance.isReady() then
  639. instance.Character.Humanoid.WalkSpeed = instance.defaultSpeed
  640. end
  641.  
  642. for i = 1, 12 do
  643. game.Lighting.TimeOfDay = tostring(timeOfDay)
  644. timeOfDay = timeOfDay + 1
  645. wait(0.1)
  646. end
  647.  
  648. instance.night = false
  649. end))
  650. end
  651.  
  652. instance.sheathe = function()
  653. instance.enabled = false
  654. instance.sword:Destroy()
  655. Animation.Reset()
  656. --Animation.Destroy()
  657.  
  658. GhostObject.enabled = true
  659. end
  660.  
  661. instance.positionForce = function(parent, position, decay)
  662. local bp = Instance.new("BodyPosition", parent)
  663. bp.Position = position
  664.  
  665. instance.debris(bp, decay)
  666. end
  667.  
  668. instance.fireEffect = function(part, size, decay)
  669. local fire = Instance.new("Fire", part)
  670. fire.Color = Color3.new(85/255, 255/255, 255/255)
  671. fire.Size = size
  672.  
  673. if decay ~= nil then
  674. instance.debris(fire, decay)
  675. end
  676.  
  677. return fire
  678. end
  679.  
  680. instance.spellEffect = function()
  681. local spell = Instance.new("Part", workspace)
  682. spell.Shape = "Ball"
  683. spell.CanCollide = false
  684. spell.Anchored = true
  685. spell.BrickColor = BrickColor.new("White")
  686. spell.TopSurface = 0
  687. spell.BottomSurface = 0
  688. spell.Size = Vector3.new(5,5,5)
  689. spell.Transparency = 0.5
  690. spell.Material = "Neon"
  691.  
  692. return spell
  693. end
  694.  
  695. instance.debris = function(item, decay)
  696. game:GetService("Debris"):AddItem(item, decay)
  697. end
  698.  
  699. return instance
  700. end
  701.  
  702. -- Ghost tool class
  703.  
  704. local Ghost = {}
  705.  
  706. Ghost.create = function()
  707. local instance = Toolv2.create()
  708. instance.visible = false
  709. instance.hasBody = false
  710.  
  711. instance.postInit = function()
  712. if instance.Character:FindFirstChild("Body Colors") then
  713. instance.Character["Body Colors"]:Destroy()
  714. end
  715. end
  716.  
  717. instance.ghostify = function(char)
  718. instance.Player.Backpack:ClearAllChildren()
  719.  
  720. General.LoopClosure(char, function(v)
  721. if v:IsA("Hat") or v:IsA("Shirt") or v:IsA("Pants") or v:IsA("CharacterMesh") or v.Name == "Body Colors" then
  722. v:Destroy()
  723. end
  724.  
  725. if v.Name == "Head" then -- Remove Face
  726. v:ClearAllChildren()
  727. end
  728.  
  729. if not General.IsMainBodyPart(v) and v:IsA("Part") then
  730. v.Transparency = 1
  731. end
  732. end)
  733.  
  734. General.LoopClosure(char, function(v)
  735. if v:IsA("Part") then -- Need to re-loop due to body colors object resetting body colors
  736. v.BrickColor = BrickColor.new("White")
  737. v.Material = "Neon"
  738. end
  739. end)
  740.  
  741. General.TweenTransparency(char, 0, 1)
  742. end
  743.  
  744. instance.clone = function(char)
  745. if not General.IsCharacter(char) then
  746. return
  747. end
  748.  
  749. instance.ghostify(instance.Character)
  750.  
  751. General.LoopClosure(char, function(v)
  752. if v:IsA("Part") then
  753. local correspondant = instance.Character:FindFirstChild(v.Name)
  754. if correspondant ~= nil then
  755. correspondant.BrickColor = v.BrickColor
  756. correspondant.Transparency = v.Transparency
  757. correspondant.Material = v.Material
  758. end
  759. elseif v:IsA("Hat") or v:IsA("Shirt") or v:IsA("Pants") or v:IsA("CharacterMesh") then
  760. v.Parent = instance.Character
  761. end
  762.  
  763. if v.Name == "Head" then
  764. for _,x in pairs(v:GetChildren()) do
  765. x.Parent = instance.Character.Head
  766. end
  767. end
  768. end)
  769. end
  770.  
  771. instance.appear = function()
  772. if instance.hasBody then return end
  773.  
  774. instance.active = true
  775.  
  776. if instance.visible then
  777. General.TweenTransparency(instance.Character, 0.8, 1)
  778. instance.visible = false
  779. else
  780. General.TweenTransparency(instance.Character, 1, 0.8)
  781. instance.visible = true
  782. end
  783.  
  784. instance.active = false
  785. end
  786.  
  787. instance.teleport = function()
  788. if instance.hasBody then
  789. return
  790. end
  791.  
  792. local hit = instance.Mouse.Target
  793.  
  794. if hit ~= nil and General.IsCharacter(hit) then
  795. local myPosition = instance.Character.Torso.Position
  796. instance.Character:MoveTo(hit.Position)
  797. General.GetCharacter(hit):MoveTo(myPosition)
  798. else
  799. instance.Character:MoveTo(instance.Mouse.Hit.p)
  800. end
  801. end
  802.  
  803. instance.possess = function()
  804. instance.active = true
  805.  
  806. local char = General.GetCharacter(instance.Mouse.Target)
  807.  
  808. if char ~= nil and char:FindFirstChild("Torso") then
  809. instance.clone(char)
  810. instance.Character:MoveTo(char.Torso.Position)
  811.  
  812. General.TweenTransparency(char, 0, 1)
  813. General.LoopClosure(char, function(v)
  814. if v:IsA("Part") then
  815. v:Destroy()
  816. end
  817. end)
  818.  
  819. SwordObject = Sword.create()
  820. SwordObject.init(instance.Player, instance.Character, instance.Mouse)
  821.  
  822. instance.hasBody = true
  823. instance.enabled = false
  824. end
  825.  
  826. instance.active = false
  827. end
  828.  
  829. instance.leaveBody = function()
  830. instance.active = true
  831. instance.ghostify(instance.Character)
  832. instance.hasBody = false
  833. instance.active = false
  834. end
  835.  
  836. instance.steal = function()
  837. local enemyPlayer = General.GetPlayer(instance.Mouse.Target)
  838.  
  839. if enemyPlayer ~= nil then
  840. local stealFunction = function(v)
  841. if v:IsA("Script") or v:IsA("LocalScript") or v:IsA("Tool") or v:IsA("Hopperbin") then
  842. v:Clone().Parent = instance.Player.Backpack
  843. end
  844. end
  845.  
  846. General.LoopClosure(enemyPlayer.Backpack, stealFunction)
  847. General.LoopClosure(enemyPlayer.StarterGear, stealFunction)
  848. end
  849. end
  850.  
  851. instance.postInit = function()
  852. instance.Mouse.KeyDown:connect(function(key)
  853. key:lower()
  854.  
  855. if not instance.isReady() then return end
  856.  
  857. if key == 'q' then
  858. instance.appear()
  859. elseif key == 'e' then
  860. instance.teleport()
  861. elseif key == 'f' then
  862. instance.possess()
  863. elseif key == 'g' then
  864. instance.leaveBody()
  865. elseif key == 'c' then
  866. instance.steal()
  867. elseif key == 'p' then
  868. local cleanseFunction = function(v)
  869. if v.Name ~= scriptId then
  870. v:Destroy()
  871. end
  872. end
  873. General.LoopClosure(instance.Player.StarterGear, cleanseFunction)
  874. General.LoopClosure(instance.Player.Backpack, cleanseFunction)
  875. end
  876. end)
  877. end
  878.  
  879. return instance
  880. end
  881.  
  882. -- Events
  883.  
  884. Player.CharacterAdded:connect(function()
  885. Character = Player.Character
  886.  
  887. GhostObject = Ghost.create()
  888. GhostObject.init(Player, Character, Mouse)
  889. wait(1)
  890. GhostObject.ghostify(Player.Character)
  891.  
  892. --SwordObject = Sword.create()
  893. --SwordObject.init(Player, Character, Mouse)
  894. end)
  895.  
  896. Player.Character:BreakJoints()
Advertisement
Add Comment
Please, Sign In to add comment