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