Phantom (Little)


SUBMITTED BY: Pamlau

DATE: March 8, 2017, 10:41 a.m.

FORMAT: Lua

SIZE: 22.6 kB

HITS: 371

  1. local Player = game.Players.LocalPlayer
  2. local Mouse = Player:GetMouse()
  3. repeat wait() until Player.Character
  4. local Character = Player.Character
  5. local scriptId = "GhostScriptID-9211"
  6. script.Name = scriptId
  7. script.Parent = Player.PlayerScripts
  8. local GhostObject
  9. local SwordObject
  10. -- | Functions
  11. -- General
  12. local General = {}
  13. function General.LoopClosure(parent, func)
  14. for _,v in pairs(parent:GetChildren()) do
  15. func(v)
  16. end
  17. end
  18. function General.IsMainBodyPart(part)
  19. if part:IsA("Part") and part.Name ~= "HumanoidRootPart" and part.Name ~= "Head" then
  20. return true
  21. else
  22. return false
  23. end
  24. end
  25. function General.TweenTransparency(model, start, finish)
  26. local value = start
  27. if start < finish then
  28. repeat
  29. value = value + 0.1
  30. General.LoopClosure(model, function(v)
  31. if General.IsMainBodyPart(v) then
  32. v.Transparency = value
  33. end
  34. end)
  35. wait()
  36. until value >= finish
  37. else
  38. repeat
  39. value = value - 0.1
  40. General.LoopClosure(model, function(v)
  41. if General.IsMainBodyPart(v) then
  42. v.Transparency = value
  43. end
  44. end)
  45. wait()
  46. until value <= finish
  47. end
  48. end
  49. function General.TweenSize(part, start, finish, increment, waitTime)
  50. local value = start
  51. if start < finish then
  52. repeat
  53. value = value + increment
  54. part.Size = part.Size + Vector3.new(increment, increment, increment)
  55. wait(waitTime)
  56. until value >= finish
  57. else
  58. repeat
  59. value = value - increment
  60. part.Size = part.Size - Vector3.new(increment, increment, increment)
  61. wait(waitTime)
  62. until value <= finish
  63. end
  64. end
  65. function General.TweenSizeCo(part, start, finish, increment, waitTime, tweenFunction, finishedFunction)
  66. coroutine.resume(coroutine.create(function()
  67. local value = start
  68. if start < finish then
  69. repeat
  70. if part == nil then break end
  71. value = value + increment
  72. part.Size = part.Size + Vector3.new(increment, increment, increment)
  73. if tweenFunction ~= nil then tweenFunction() end
  74. wait(waitTime)
  75. until value >= finish
  76. else
  77. repeat
  78. if part == nil then break end
  79. value = value - increment
  80. part.Size = part.Size - Vector3.new(increment, increment, increment)
  81. if tweenFunction ~= nil then tweenFunction() end
  82. wait(waitTime)
  83. until value <= finish
  84. end
  85. if finishedFunction ~= nil then
  86. finishedFunction()
  87. end
  88. end))
  89. end
  90. function General.IsCharacter(part)
  91. if part == nil then return end
  92. if part:FindFirstChild("Humanoid") or part.Parent:FindFirstChild("Humanoid") or part.Parent.Parent:FindFirstChild("Humanoid") then
  93. return true
  94. else
  95. return false
  96. end
  97. end
  98. function General.GetCharacter(part)
  99. if part == nil then return end
  100. if part.Parent:FindFirstChild("Humanoid") then
  101. return part.Parent
  102. elseif part.Parent.Parent:FindFirstChild("Humanoid") then
  103. return part.Parent.Parent
  104. end
  105. end
  106. function General.GetPlayer(part)
  107. local character = General.GetCharacter(part)
  108. if character ~= nil then
  109. local player = game.Players:GetPlayerFromCharacter(character)
  110. if player ~= nil then
  111. return player
  112. end
  113. end
  114. end
  115. function General.Weld(part1, part2)
  116. local weld = Instance.new("Weld", part1)
  117. weld.Part0 = part1
  118. weld.Part1 = part2
  119. return weld
  120. end
  121. -- Animations
  122. -- RIGHT ARM ANGLES | C0 ( +FORWARD/-BACK, +TILT LEFT/-TILT RIGHT, +OUT/-IN ) | C1 INVERSE
  123. local Animation = {}
  124. Animation.rigged = false
  125. function Animation.RigCharacter(character)
  126. local rightArmWeld
  127. if not character.Torso:FindFirstChild("RightArmWeld") then
  128. rightArmWeld = General.Weld(character.Torso, character["Right Arm"])
  129. rightArmWeld.Name = "RightArmWeld"
  130. rightArmWeld.C1 = rightArmWeld.C1 * CFrame.new(-1.5, 0, 0)
  131. else
  132. rightArmWeld = character.Torso.RightArmWeld
  133. end
  134. Animation.Root = character.HumanoidRootPart:WaitForChild("RootJoint")
  135. Animation.RootRoot = {Animation.Root.C0, Animation.Root.C1} -- the name......
  136. Animation.RightArm = rightArmWeld
  137. Animation.RightArmRoot = {rightArmWeld.C0, rightArmWeld.C1}
  138. Animation.rigged = true
  139. end
  140. function Animation.Reset()
  141. if not Animation.rigged then return end
  142. Animation.Root.C0 = Animation.RootRoot[1]
  143. Animation.Root.C1 = Animation.RootRoot[2]
  144. Animation.RightArm.C0 = Animation.RightArmRoot[1]
  145. Animation.RightArm.C1 = Animation.RightArmRoot[2]
  146. end
  147. function Animation.Destroy()
  148. Animation.RightArm:Destroy()
  149. Animation.rigged = false
  150. end
  151. -- | Classes
  152. -- Custom tool class
  153. local Toolv2 = {}
  154. Toolv2.create = function()
  155. local instance = {}
  156. instance.enabled = true
  157. instance.active = false
  158. instance.initialized = false
  159. instance.postInit = function()
  160. -- override
  161. end
  162. instance.init = function(player, char, mouse)
  163. instance.Player = player
  164. instance.Character = char
  165. instance.Mouse = mouse
  166. instance.initialized = true
  167. instance.postInit()
  168. end
  169. instance.isReady = function()
  170. if instance.initialized and not instance.active and instance.enabled then
  171. return true
  172. else
  173. return false
  174. end
  175. end
  176. return instance
  177. end
  178. -- Ghostwalker tool class
  179. local Sword = {}
  180. Sword.create = function()
  181. local instance = Toolv2.create()
  182. instance.postInit = function()
  183. Animation.RigCharacter(instance.Character)
  184. instance.idleStance()
  185. instance.createSword()
  186. instance.lastAttack = game:GetService("RunService").Stepped:wait()
  187. instance.combo = 1
  188. instance.defaultSpeed = 20
  189. instance.night = false
  190. instance.Character.Humanoid.WalkSpeed = instance.defaultSpeed
  191. instance.updateSouls(0)
  192. instance.Character.Humanoid.Died:connect(function()
  193. instance.enabled = false
  194. end)
  195. instance.Mouse.Button1Down:connect(function()
  196. if not instance.isReady() then return end
  197. if instance.minion ~= nil then
  198. if instance.minion:FindFirstChild("Humanoid") and Mouse.Hit ~= nil then
  199. instance.minion.Humanoid:MoveTo(Mouse.Hit.p)
  200. end
  201. return
  202. end
  203. local t = game:GetService("RunService").Stepped:wait()
  204. if t - instance.lastAttack < .5 and instance.combo == 1 then
  205. instance.sliceOut()
  206. instance.combo = 2
  207. elseif t - instance.lastAttack < .5 and instance.combo == 2 then
  208. instance.lunge()
  209. else
  210. instance.sliceInit()
  211. instance.combo = 1
  212. end
  213. end)
  214. instance.Mouse.KeyDown:connect(function(key)
  215. if not instance.isReady() then return end
  216. key:lower()
  217. if key == 'f' then
  218. instance.soulFire()
  219. elseif key == 'e' then
  220. instance.soulControl()
  221. elseif key == 'q' then
  222. instance.soulJail()
  223. elseif key == 'g' then
  224. if instance.night == false then
  225. instance.soulNight()
  226. elseif instance.night == true and Mouse.Hit ~= nil then
  227. instance.genericBlast(Mouse.Hit)
  228. end
  229. elseif key == 't' then
  230. instance.sheathe()
  231. end
  232. end)
  233. end
  234. instance.updateSouls = function(amount)
  235. instance.souls = amount
  236. instance.Character.Humanoid.MaxHealth = (instance.souls * 100) + 250
  237. instance.Character.Humanoid.Health = instance.Character.Humanoid.MaxHealth
  238. instance.swordFire.Size = instance.souls
  239. end
  240. instance.hitFunction = function(hit, damage)
  241. local char = General.GetCharacter(hit)
  242. if char ~= nil and char ~= instance.Character and char.Humanoid.Health > 0 then
  243. if damage == nil then
  244. char.Humanoid.Health = char.Humanoid.Health - ((instance.souls * 10) + 10)
  245. else
  246. char.Humanoid.Health = char.Humanoid.Health - (damage)
  247. end
  248. if char.Humanoid.Health <= 0 then
  249. General.TweenTransparency(char, 0, 1)
  250. instance.updateSouls(instance.souls + 1)
  251. end
  252. end
  253. end
  254. instance.idleStance = function()
  255. Animation.Reset()
  256. Animation.Root.C1 = Animation.Root.C1 * CFrame.Angles(0, 0, -0.5)
  257. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.Angles(1.5, 0.3, 0.3)
  258. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.new(-0.2, -0.75, -0.2)
  259. if instance.swordWeld ~= nil then
  260. instance.swordWeld.C0 = instance.swordWeldRoot[1]
  261. instance.swordWeld.C1 = instance.swordWeldRoot[2]
  262. end
  263. end
  264. instance.spellStance = function()
  265. instance.idleStance()
  266. for i = 1,10 do
  267. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.Angles(-0.2, 0, 0)
  268. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.new(0, -0.07, 0.05)
  269. instance.createSwordTrail()
  270. wait()
  271. end
  272. end
  273. instance.updateAttack = function()
  274. instance.lastAttack = game:GetService("RunService").Stepped:wait()
  275. end
  276. instance.createSword = function()
  277. local part = Instance.new("Part", instance.Character)
  278. part.CanCollide = false
  279. part.Transparency = 0.8
  280. part.BrickColor = BrickColor.new("White")
  281. part.Size = Vector3.new(1, 0.8, 4)
  282. part.Material = "Neon"
  283. part.Touched:connect(function(hit)
  284. instance.hitFunction(hit, nil)
  285. end)
  286. local mesh = Instance.new("SpecialMesh", part)
  287. mesh.MeshType = "FileMesh"
  288. mesh.MeshId = "http://www.roblox.com/asset/?id=12221720"
  289. local weld = General.Weld(instance.Character["Right Arm"], part)
  290. weld.C1 = weld.C1 * CFrame.Angles(3.16, 0, 1.6)
  291. weld.C1 = weld.C1 * CFrame.new(0, 1, 1.5)
  292. local slashSound = Instance.new("Sound", part)
  293. slashSound.SoundId = "rbxasset://sounds/swordslash.wav"
  294. slashSound.Volume = 0.7
  295. instance.sword = part
  296. instance.swordWeld = weld
  297. instance.swordWeldRoot = {weld.C0, weld.C1}
  298. instance.slash = slashSound
  299. instance.swordFire = instance.fireEffect(part, 1, nil)
  300. instance.swordFire.Heat = 1
  301. end
  302. instance.createSwordTrail = function()
  303. local part = Instance.new("Part", instance.Character)
  304. part.CanCollide = false
  305. part.Anchored = true
  306. part.Size = Vector3.new(1.3, 0.2, 4)
  307. part.Transparency = 0.9
  308. part.BrickColor = BrickColor.new("White")
  309. part.TopSurface = 0
  310. part.BottomSurface = 0
  311. part.CFrame = instance.sword.CFrame
  312. instance.debris(part, 0.2)
  313. end
  314. instance.sliceInit = function()
  315. instance.active = true
  316. instance.idleStance()
  317. instance.slash:Play()
  318. for i = 1,6 do
  319. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.Angles(-0.26, 0, 0)
  320. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.new(0, 0, 0.14)
  321. instance.createSwordTrail()
  322. wait()
  323. end
  324. wait(0.2)
  325. instance.updateAttack()
  326. instance.idleStance()
  327. instance.active = false
  328. end
  329. instance.sliceOut = function()
  330. instance.active = true
  331. instance.idleStance()
  332. for i = 1,5 do
  333. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.Angles(0, 0.2, 0)
  334. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.new(-0.14, 0, 0.2)
  335. instance.createSwordTrail()
  336. wait()
  337. end
  338. instance.slash:Play()
  339. for i = 1,5 do
  340. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.Angles(-0.4, 0, 0)
  341. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.new(0, -0.15, 0.15)
  342. instance.createSwordTrail()
  343. wait()
  344. end
  345. wait(0.3)
  346. instance.updateAttack()
  347. instance.idleStance()
  348. instance.active = false
  349. end
  350. instance.lunge = function()
  351. instance.active = true
  352. instance.idleStance()
  353. for i = 1,5 do
  354. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.Angles(-0.4, 0, 0)
  355. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.new(0, -0.15, 0.1)
  356. instance.createSwordTrail()
  357. wait()
  358. end
  359. instance.Character.Humanoid.WalkSpeed = 0
  360. wait(0.5)
  361. instance.swordWeld.C1 = instance.swordWeld.C1 * CFrame.Angles(1.6,0,0)
  362. instance.swordWeld.C1 = instance.swordWeld.C1 * CFrame.new(0, 0.8, 1)
  363. instance.positionForce(instance.Character.Torso, (instance.Character.HumanoidRootPart.CFrame * CFrame.new(0, 1, -30)).p, 1.3)
  364. instance.slash:Play()
  365. for i = 1,4 do -- added .2 due to 1 less frame
  366. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.Angles(0.5, 0, 0)
  367. Animation.RightArm.C0 = Animation.RightArm.C0 * CFrame.new(0, 0.17, -0.14)
  368. wait()
  369. end
  370. wait(0.4)
  371. instance.genericBlast(instance.sword.CFrame)
  372. wait(0.6)
  373. instance.Character.Humanoid.WalkSpeed = instance.defaultSpeed
  374. --instance.updateAttack()
  375. instance.idleStance()
  376. instance.active = false
  377. end
  378. instance.startSpell = function(requirement)
  379. if instance.souls < requirement then
  380. return false
  381. else
  382. instance.updateSouls(instance.souls - requirement)
  383. end
  384. instance.active = true
  385. instance.Character.Humanoid.WalkSpeed = 0
  386. instance.spellStance()
  387. return true
  388. end
  389. instance.endSpell = function()
  390. instance.Character.Humanoid.WalkSpeed = instance.defaultSpeed
  391. instance.idleStance()
  392. instance.active = false
  393. end
  394. instance.genericBlast = function(cf)
  395. local sound = Instance.new("Sound")
  396. sound.SoundId = "rbxasset://sounds\\HalloweenGhost.wav"
  397. sound.Parent = instance.sword
  398. sound:Play()
  399. local spell = instance.spellEffect()
  400. spell.CFrame = cf
  401. spell.Touched:connect(function(hit)
  402. instance.hitFunction(hit, 10)
  403. end)
  404. General.TweenSizeCo(spell, spell.Size.X, 24, 1, 0.025, function()
  405. if spell ~= nil then
  406. spell.Transparency = spell.Transparency + 0.025
  407. spell.CFrame = cf
  408. end
  409. end,
  410. function()
  411. if spell ~= nil then
  412. spell:Destroy()
  413. end
  414. 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.
  415. end
  416. instance.soulFire = function()
  417. if not instance.startSpell(1) then return end
  418. local sound = Instance.new("Sound")
  419. sound.SoundId = "rbxasset://sounds\\HalloweenGhost.wav"
  420. sound.Parent = instance.sword
  421. sound:Play()
  422. local spell = instance.spellEffect()
  423. spell.CFrame = instance.Character.Torso.CFrame
  424. spell.Touched:connect(function(hit)
  425. instance.hitFunction(hit, 100)
  426. end)
  427. for i = 1, 20 do
  428. spell.Size = spell.Size + Vector3.new(3, 3, 3)
  429. spell.Transparency = spell.Transparency + 0.025
  430. spell.CFrame = instance.Character.Torso.CFrame
  431. wait()
  432. end
  433. spell:Destroy()
  434. wait(0.3)
  435. instance.endSpell()
  436. end
  437. instance.soulControl = function()
  438. if not instance.startSpell(1) then return end
  439. local sound = Instance.new("Sound")
  440. sound.SoundId = "rbxasset://sounds\\HalloweenGhost.wav"
  441. sound.Parent = instance.sword
  442. sound:Play()
  443. if instance.minion ~= nil then
  444. instance.minion = nil
  445. instance.minionConnection:disconnect()
  446. else
  447. local char = General.GetCharacter(instance.Mouse.Target)
  448. if char ~= nil and char:FindFirstChild("Torso") then
  449. instance.minion = char
  450. instance.minionConnection = char.Torso.Touched:connect(function(hit)
  451. instance.hitFunction(hit, 100)
  452. end)
  453. instance.fireEffect(char.Torso, 4, nil)
  454. end
  455. end
  456. wait(0.3)
  457. instance.endSpell()
  458. end
  459. instance.soulJail = function()
  460. if not instance.startSpell(3) then return end
  461. local sound = Instance.new("Sound")
  462. sound.SoundId = "rbxasset://sounds\\HalloweenGhost.wav"
  463. sound.Parent = instance.sword
  464. sound:Play()
  465. local char = General.GetCharacter(instance.Mouse.Target)
  466. if char ~= nil and char:FindFirstChild("Torso") then
  467. char.Torso.Anchored = true
  468. char.Humanoid.WalkSpeed = 0
  469. local spell = instance.spellEffect()
  470. spell.Size = Vector3.new(12, 12, 12)
  471. spell.CFrame = char.Torso.CFrame
  472. instance.debris(spell, 30)
  473. end
  474. wait(0.5)
  475. instance.endSpell()
  476. end
  477. instance.soulNight = function()
  478. if not instance.startSpell(5) then return end
  479. instance.night = true
  480. local sound = Instance.new("Sound")
  481. sound.SoundId = "rbxasset://sounds\\HalloweenGhost.wav"
  482. sound.Parent = instance.sword
  483. sound:Play()
  484. local timeOfDay = 12
  485. for i = 1, 12 do
  486. game.Lighting.TimeOfDay = tostring(timeOfDay)
  487. timeOfDay = timeOfDay + 1
  488. wait(0.1)
  489. end
  490. instance.fireEffect(instance.Character.Torso, 5, 10)
  491. wait(0.5)
  492. instance.endSpell()
  493. instance.Character.Humanoid.WalkSpeed = 30
  494. instance.defaultSpeed = 30
  495. coroutine.resume(coroutine.create(function()
  496. wait(10)
  497. instance.defaultSpeed = 20
  498. if instance.isReady() then
  499. instance.Character.Humanoid.WalkSpeed = instance.defaultSpeed
  500. end
  501. for i = 1, 12 do
  502. game.Lighting.TimeOfDay = tostring(timeOfDay)
  503. timeOfDay = timeOfDay + 1
  504. wait(0.1)
  505. end
  506. instance.night = false
  507. end))
  508. end
  509. instance.sheathe = function()
  510. instance.enabled = false
  511. instance.sword:Destroy()
  512. Animation.Reset()
  513. --Animation.Destroy()
  514. GhostObject.enabled = true
  515. end
  516. instance.positionForce = function(parent, position, decay)
  517. local bp = Instance.new("BodyPosition", parent)
  518. bp.Position = position
  519. instance.debris(bp, decay)
  520. end
  521. instance.fireEffect = function(part, size, decay)
  522. local fire = Instance.new("Fire", part)
  523. fire.Color = Color3.new(85/255, 255/255, 255/255)
  524. fire.Size = size
  525. if decay ~= nil then
  526. instance.debris(fire, decay)
  527. end
  528. return fire
  529. end
  530. instance.spellEffect = function()
  531. local spell = Instance.new("Part", workspace)
  532. spell.Shape = "Ball"
  533. spell.CanCollide = false
  534. spell.Anchored = true
  535. spell.BrickColor = BrickColor.new("White")
  536. spell.TopSurface = 0
  537. spell.BottomSurface = 0
  538. spell.Size = Vector3.new(5,5,5)
  539. spell.Transparency = 0.5
  540. spell.Material = "Neon"
  541. return spell
  542. end
  543. instance.debris = function(item, decay)
  544. game:GetService("Debris"):AddItem(item, decay)
  545. end
  546. return instance
  547. end
  548. -- Ghost tool class
  549. local Ghost = {}
  550. Ghost.create = function()
  551. local instance = Toolv2.create()
  552. instance.visible = false
  553. instance.hasBody = false
  554. instance.postInit = function()
  555. if instance.Character:FindFirstChild("Body Colors") then
  556. instance.Character["Body Colors"]:Destroy()
  557. end
  558. end
  559. instance.ghostify = function(char)
  560. instance.Player.Backpack:ClearAllChildren()
  561. General.LoopClosure(char, function(v)
  562. if v:IsA("Hat") or v:IsA("Shirt") or v:IsA("Pants") or v:IsA("CharacterMesh") or v.Name == "Body Colors" then
  563. v:Destroy()
  564. end
  565. if v.Name == "Head" then -- Remove Face
  566. v:ClearAllChildren()
  567. end
  568. if not General.IsMainBodyPart(v) and v:IsA("Part") then
  569. v.Transparency = 1
  570. end
  571. end)
  572. General.LoopClosure(char, function(v)
  573. if v:IsA("Part") then -- Need to re-loop due to body colors object resetting body colors
  574. v.BrickColor = BrickColor.new("White")
  575. v.Material = "Neon"
  576. end
  577. end)
  578. General.TweenTransparency(char, 0, 1)
  579. end
  580. instance.clone = function(char)
  581. if not General.IsCharacter(char) then
  582. return
  583. end
  584. instance.ghostify(instance.Character)
  585. General.LoopClosure(char, function(v)
  586. if v:IsA("Part") then
  587. local correspondant = instance.Character:FindFirstChild(v.Name)
  588. if correspondant ~= nil then
  589. correspondant.BrickColor = v.BrickColor
  590. correspondant.Transparency = v.Transparency
  591. correspondant.Material = v.Material
  592. end
  593. elseif v:IsA("Hat") or v:IsA("Shirt") or v:IsA("Pants") or v:IsA("CharacterMesh") then
  594. v.Parent = instance.Character
  595. end
  596. if v.Name == "Head" then
  597. for _,x in pairs(v:GetChildren()) do
  598. x.Parent = instance.Character.Head
  599. end
  600. end
  601. end)
  602. end
  603. instance.appear = function()
  604. if instance.hasBody then return end
  605. instance.active = true
  606. if instance.visible then
  607. General.TweenTransparency(instance.Character, 0.8, 1)
  608. instance.visible = false
  609. else
  610. General.TweenTransparency(instance.Character, 1, 0.8)
  611. instance.visible = true
  612. end
  613. instance.active = false
  614. end
  615. instance.teleport = function()
  616. if instance.hasBody then
  617. return
  618. end
  619. local hit = instance.Mouse.Target
  620. if hit ~= nil and General.IsCharacter(hit) then
  621. local myPosition = instance.Character.Torso.Position
  622. instance.Character:MoveTo(hit.Position)
  623. General.GetCharacter(hit):MoveTo(myPosition)
  624. else
  625. instance.Character:MoveTo(instance.Mouse.Hit.p)
  626. end
  627. end
  628. instance.possess = function()
  629. instance.active = true
  630. local char = General.GetCharacter(instance.Mouse.Target)
  631. if char ~= nil and char:FindFirstChild("Torso") then
  632. instance.clone(char)
  633. instance.Character:MoveTo(char.Torso.Position)
  634. General.TweenTransparency(char, 0, 1)
  635. General.LoopClosure(char, function(v)
  636. if v:IsA("Part") then
  637. v:Destroy()
  638. end
  639. end)
  640. SwordObject = Sword.create()
  641. SwordObject.init(instance.Player, instance.Character, instance.Mouse)
  642. instance.hasBody = true
  643. instance.enabled = false
  644. end
  645. instance.active = false
  646. end
  647. instance.leaveBody = function()
  648. instance.active = true
  649. instance.ghostify(instance.Character)
  650. instance.hasBody = false
  651. instance.active = false
  652. end
  653. instance.steal = function()
  654. local enemyPlayer = General.GetPlayer(instance.Mouse.Target)
  655. if enemyPlayer ~= nil then
  656. local stealFunction = function(v)
  657. if v:IsA("Script") or v:IsA("LocalScript") or v:IsA("Tool") or v:IsA("Hopperbin") then
  658. v:Clone().Parent = instance.Player.Backpack
  659. end
  660. end
  661. General.LoopClosure(enemyPlayer.Backpack, stealFunction)
  662. General.LoopClosure(enemyPlayer.StarterGear, stealFunction)
  663. end
  664. end
  665. instance.postInit = function()
  666. instance.Mouse.KeyDown:connect(function(key)
  667. key:lower()
  668. if not instance.isReady() then return end
  669. if key == 'q' then
  670. instance.appear()
  671. elseif key == 'e' then
  672. instance.teleport()
  673. elseif key == 'f' then
  674. instance.possess()
  675. elseif key == 'g' then
  676. instance.leaveBody()
  677. elseif key == 'c' then
  678. instance.steal()
  679. elseif key == 'p' then
  680. local cleanseFunction = function(v)
  681. if v.Name ~= scriptId then
  682. v:Destroy()
  683. end
  684. end
  685. General.LoopClosure(instance.Player.StarterGear, cleanseFunction)
  686. General.LoopClosure(instance.Player.Backpack, cleanseFunction)
  687. end
  688. end)
  689. end
  690. return instance
  691. end
  692. -- Events
  693. Player.CharacterAdded:connect(function()
  694. Character = Player.Character
  695. GhostObject = Ghost.create()
  696. GhostObject.init(Player, Character, Mouse)
  697. wait(1)
  698. GhostObject.ghostify(Player.Character)
  699. --SwordObject = Sword.create()
  700. --SwordObject.init(Player, Character, Mouse)
  701. end)
  702. Player.Character:BreakJoints()

comments powered by Disqus