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