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