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