local i=waitForChild(sp,"\084\111\114\115\111")local M=waitForChild(sp,"\072\101\097\100")local Y=waitForChild(i,"\082\105\103\104\116 \083\104\111\117\108\100\101\114")local U=waitForChild(i,"\076\101\102\116 \083\104\111\117\108\100\101\114")local X=waitForChild(i,"\082\105\103\104\116 \072\105\112")local C=waitForChild(i,"\076\101\102\116 \072\105\112")local I=waitForChild(i,"\078\101\099\107")local a=waitForChild(sp,"\072\117\109\097\110\111\105\100")local n="\083\116\097\110\100\105\110\103"local B=waitForChild(i,"\072\105\116\083\111\117\110\100")local L={waitForChild(i,"\071\104\111\115\116\049\083\111\117\110\100");waitForChild(i,"\071\104\111\115\116\050\083\111\117\110\100")}if healthregen then local i=waitForChild(sp,"\072\101\097\108\116\104\082\101\103\101\110\101\114\097\116\105\111\110\083\099\114\105\112\116")i.Disabled=false end a.WalkSpeed=wonderspeed local K="\078\111\110\101"local N=0 function onRunning(i)if i>0 then n="\082\117\110\110\105\110\103"else n="\083\116\097\110\100\105\110\103"end end function onDied()n="\068\101\097\100"end function onJumping()n="\074\117\109\112\105\110\103"end function onClimbing()n="\067\108\105\109\098\105\110\103"end function onGettingUp()n="\071\101\116\116\105\110\103\085\112"end function onFreeFall()n="\070\114\101\101\070\097\108\108"end function onFallingDown()n="\070\097\108\108\105\110\103\068\111\119\110"end function onSeated()n="\083\101\097\116\101\100"end function onPlatformStanding()n="\080\108\097\116\102\111\114\109\083\116\097\110\100\105\110\103"end function moveJump()Y.MaxVelocity=.5 U.MaxVelocity=.5 Y.DesiredAngle=3.14 U.DesiredAngle=-3.14 X.DesiredAngle=0 C.DesiredAngle=0 end function moveFreeFall()Y.MaxVelocity=.5 U.MaxVelocity=.5 Y.DesiredAngle=3.14 U.DesiredAngle=-3.14 X.DesiredAngle=0 C.DesiredAngle=0 end function moveSit()Y.MaxVelocity=.15 U.MaxVelocity=.15 Y.DesiredAngle=1.57 U.DesiredAngle=-1.57 X.DesiredAngle=1.57 C.DesiredAngle=-1.57 end function animate(i)local M local I if n=="\074\117\109\112\105\110\103"then moveJump()return end if n=="\070\114\101\101\070\097\108\108"then moveFreeFall()return end if n=="\083\101\097\116\101\100"then moveSit()return end local a=0 if n=="\082\117\110\110\105\110\103"then Y.MaxVelocity=.15 U.MaxVelocity=.15 M=1 I=9 elseif n=="\067\108\105\109\098\105\110\103"then Y.MaxVelocity=.5 U.MaxVelocity=.5 M=1 I=9 a=3.14 else M=.1 I=1 end desiredAngle=M*math.sin(i*I)if not chasing and I==9 then I=4 end if chasing then Y.DesiredAngle=math.pi/2 U.DesiredAngle=-math.pi/2 X.DesiredAngle=-desiredAngle*2 C.DesiredAngle=-desiredAngle*2 else Y.DesiredAngle=desiredAngle+a U.DesiredAngle=desiredAngle-a X.DesiredAngle=-desiredAngle C.DesiredAngle=-desiredAngle end end function attack(M,X)if M-lastattack>=1 then local C,I=raycast(i.Position,(X-i.Position).unit,attackrange)if C and(C.Parent~=nil and C.Parent.Name~=sp.Name)then local i=C.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")if i then local M=sp:FindFirstChild("\099\114\101\097\116\111\114")if M then if M.Value~=nil then if M.Value~=game.Players:GetPlayerFromCharacter(i.Parent)then for i,M in ipairs(i:GetChildren())do if M.Name=="\099\114\101\097\116\111\114"then M:remove()end end;(M:clone()).Parent=i else return end end end i:TakeDamage(damage)B.Volume=.5+.5*math.random()B.Pitch=.5+math.random()B:Play()if Y and U then Y.CurrentAngle=0 U.CurrentAngle=0 end end end lastattack=M end end a.Died:connect(onDied)a.Running:connect(onRunning)a.Jumping:connect(onJumping)a.Climbing:connect(onClimbing)a.GettingUp:connect(onGettingUp)a.FreeFalling:connect(onFreeFall)a.FallingDown:connect(onFallingDown)a.Seated:connect(onSeated)a.PlatformStanding:connect(onPlatformStanding)function populatehumanoids(i)if i.ClassName=="\072\117\109\097\110\111\105\100"then table.insert(humanoids,i)end for i,M in ipairs(i:GetChildren())do populatehumanoids(M)end end function playsound(i)nextsound=(i+5)+math.random()*5 local M=L[math.random(1,#L)]M.Volume=1 M.Pitch=1 M:Play()end while sp.Parent~=nil and(a and(a.Parent~=nil and(a.Health>0 and(i and(M and(i~=nil and i.Parent~=nil))))))do local M,Y=wait(.33333333333333)humanoids={}populatehumanoids(game.Workspace)closesttarget=nil closestdist=sightrange local U=sp:FindFirstChild("\099\114\101\097\116\111\114")for M,Y in ipairs(humanoids)do if Y and Y.Parent~=nil then if Y.Health>0 and(Y.Parent.Name~=sp.Name and Y.Parent~=sp)then local M=game.Players:GetPlayerFromCharacter(Y.Parent)if U==nil or M==nil or U.Value~=M then local M=Y.Parent:FindFirstChild("\084\111\114\115\111")if M~=nil then local Y=(M.Position-i.Position).magnitude if Y<closestdist then closestdist=Y closesttarget=M end end end end end end if closesttarget~=nil then if not chasing then playsound(Y)chasing=true a.WalkSpeed=runspeed end a:MoveTo(closesttarget.Position+Vector3.new(1,1,1)*(variance*(math.random()*2-1)),closesttarget)if math.random()<.5 then attack(Y,closesttarget.Position)end else if chasing then chasing=false a.WalkSpeed=wonderspeed end if Y>nextrandom then nextrandom=(Y+3)+math.random()*5 local M=i.Position+(Vector3.new(1,1,1)*math.random()-Vector3.new(.5,.5,.5))*40 a:MoveTo(M,game.Workspace.Terrain)end end if Y>nextsound then playsound(Y)end if Y>nextjump then nextjump=(Y+7)+math.random()*5 a.Jump=true end animate(Y)end if sp~=nil then for i,M in ipairs(sp:GetChildren())do if M.className=="\080\097\114\116"then M.CanCollide=false end end end wait(4)sp:remove()
-- declarations

local Torso = waitForChild(sp, "Torso")
local Head = waitForChild(sp, "Head")
local RightShoulder = waitForChild(Torso, "Right Shoulder")
local LeftShoulder = waitForChild(Torso, "Left Shoulder")
local RightHip = waitForChild(Torso, "Right Hip")
local LeftHip = waitForChild(Torso, "Left Hip")
local Neck = waitForChild(Torso, "Neck")
local Humanoid = waitForChild(sp, "Humanoid")
local pose = "Standing"
local hitsound = waitForChild(Torso, "HitSound")

local sounds = {
	waitForChild(Torso, "Ghost1Sound"),
	waitForChild(Torso, "Ghost2Sound"),
}

if healthregen then
	local regenscript = waitForChild(sp, "HealthRegenerationScript")
	regenscript.Disabled = false
end
Humanoid.WalkSpeed = wonderspeed

local toolAnim = "None"
local toolAnimTime = 0

function onRunning(speed)
	if speed > 0 then
		pose = "Running"
	else
		pose = "Standing"
	end
end
function onDied()
	pose = "Dead"
end
function onJumping()
	pose = "Jumping"
end
function onClimbing()
	pose = "Climbing"
end
function onGettingUp()
	pose = "GettingUp"
end
function onFreeFall()
	pose = "FreeFall"
end
function onFallingDown()
	pose = "FallingDown"
end
function onSeated()
	pose = "Seated"
end
function onPlatformStanding()
	pose = "PlatformStanding"
end

function moveJump()
	RightShoulder.MaxVelocity = 0.5
	LeftShoulder.MaxVelocity = 0.5
	RightShoulder.DesiredAngle = 3.14
	LeftShoulder.DesiredAngle = -3.14
	RightHip.DesiredAngle = 0
	LeftHip.DesiredAngle = 0
end

function moveFreeFall()
	RightShoulder.MaxVelocity = 0.5
	LeftShoulder.MaxVelocity = 0.5
	RightShoulder.DesiredAngle = 3.14
	LeftShoulder.DesiredAngle = -3.14
	RightHip.DesiredAngle = 0
	LeftHip.DesiredAngle = 0
end

function moveSit()
	RightShoulder.MaxVelocity = 0.15
	LeftShoulder.MaxVelocity = 0.15
	RightShoulder.DesiredAngle = 3.14 / 2
	LeftShoulder.DesiredAngle = -3.14 / 2
	RightHip.DesiredAngle = 3.14 / 2
	LeftHip.DesiredAngle = -3.14 / 2
end

function animate(time)
	local amplitude
	local frequency
	if pose == "Jumping" then
		moveJump()
		return
	end
	if pose == "FreeFall" then
		moveFreeFall()
		return
	end
	if pose == "Seated" then
		moveSit()
		return
	end
	local climbFudge = 0
	if pose == "Running" then
		RightShoulder.MaxVelocity = 0.15
		LeftShoulder.MaxVelocity = 0.15
		amplitude = 1
		frequency = 9
	elseif pose == "Climbing" then
		RightShoulder.MaxVelocity = 0.5
		LeftShoulder.MaxVelocity = 0.5
		amplitude = 1
		frequency = 9
		climbFudge = 3.14
	else
		amplitude = 0.1
		frequency = 1
	end
	desiredAngle = amplitude * math.sin(time * frequency)
	if not chasing and frequency == 9 then
		frequency = 4
	end
	if chasing then
		RightShoulder.DesiredAngle = math.pi / 2
		LeftShoulder.DesiredAngle = -math.pi / 2
		RightHip.DesiredAngle = -desiredAngle * 2
		LeftHip.DesiredAngle = -desiredAngle * 2
	else
		RightShoulder.DesiredAngle = desiredAngle + climbFudge
		LeftShoulder.DesiredAngle = desiredAngle - climbFudge
		RightHip.DesiredAngle = -desiredAngle
		LeftHip.DesiredAngle = -desiredAngle
	end
end

function attack(time, attackpos)
	if time - lastattack >= 1 then
		local hit, pos = raycast(Torso.Position, (attackpos - Torso.Position).unit, attackrange)
		if hit and hit.Parent ~= nil and hit.Parent.Name ~= sp.Name then
			local h = hit.Parent:FindFirstChild("Humanoid")
			if h then
				local creator = sp:FindFirstChild("creator")
				if creator then
					if creator.Value ~= nil then
						if creator.Value ~= game.Players:GetPlayerFromCharacter(h.Parent) then
							for i, oldtag in ipairs(h:GetChildren()) do
								if oldtag.Name == "creator" then
									oldtag:remove()
								end
							end
							creator:clone().Parent = h
						else
							return
						end
					end
				end
				h:TakeDamage(damage)
				hitsound.Volume = 0.5 + (0.5 * math.random())
				hitsound.Pitch = 0.5 + math.random()
				hitsound:Play()
				if RightShoulder and LeftShoulder then
					RightShoulder.CurrentAngle = 0
					LeftShoulder.CurrentAngle = 0
				end
			end
		end
		lastattack = time
	end
end

Humanoid.Died:connect(onDied)
Humanoid.Running:connect(onRunning)
Humanoid.Jumping:connect(onJumping)
Humanoid.Climbing:connect(onClimbing)
Humanoid.GettingUp:connect(onGettingUp)
Humanoid.FreeFalling:connect(onFreeFall)
Humanoid.FallingDown:connect(onFallingDown)
Humanoid.Seated:connect(onSeated)
Humanoid.PlatformStanding:connect(onPlatformStanding)

function populatehumanoids(mdl)
	if mdl.ClassName == "Humanoid" then
		table.insert(humanoids, mdl)
	end
	for i2, mdl2 in ipairs(mdl:GetChildren()) do
		populatehumanoids(mdl2)
	end
end

function playsound(time)
	nextsound = time + 5 + (math.random() * 5)
	local randomsound = sounds[math.random(1, #sounds)]
	randomsound.Volume = 1
	randomsound.Pitch = 1
	randomsound:Play()
end

while
	sp.Parent ~= nil
	and Humanoid
	and Humanoid.Parent ~= nil
	and Humanoid.Health > 0
	and Torso
	and Head
	and Torso ~= nil
	and Torso.Parent ~= nil
do
	local _, time = wait(1 / 3)
	humanoids = {}
	populatehumanoids(game.Workspace)
	closesttarget = nil
	closestdist = sightrange
	local creator = sp:FindFirstChild("creator")
	for i, h in ipairs(humanoids) do
		if h and h.Parent ~= nil then
			if h.Health > 0 and h.Parent.Name ~= sp.Name and h.Parent ~= sp then
				local plr = game.Players:GetPlayerFromCharacter(h.Parent)
				if creator == nil or plr == nil or creator.Value ~= plr then
					local t = h.Parent:FindFirstChild("Torso")
					if t ~= nil then
						local dist = (t.Position - Torso.Position).magnitude
						if dist < closestdist then
							closestdist = dist
							closesttarget = t
						end
					end
				end
			end
		end
	end
	if closesttarget ~= nil then
		if not chasing then
			playsound(time)
			chasing = true
			Humanoid.WalkSpeed = runspeed
		end
		Humanoid:MoveTo(
			closesttarget.Position + (Vector3.new(1, 1, 1) * (variance * ((math.random() * 2) - 1))),
			closesttarget
		)
		if math.random() < 0.5 then
			attack(time, closesttarget.Position)
		end
	else
		if chasing then
			chasing = false
			Humanoid.WalkSpeed = wonderspeed
		end
		if time > nextrandom then
			nextrandom = time + 3 + (math.random() * 5)
			local randompos = Torso.Position + (
					(Vector3.new(1, 1, 1) * math.random() - Vector3.new(0.5, 0.5, 0.5)) * 40
				)
			Humanoid:MoveTo(randompos, game.Workspace.Terrain)
		end
	end
	if time > nextsound then
		playsound(time)
	end
	if time > nextjump then
		nextjump = time + 7 + (math.random() * 5)
		Humanoid.Jump = true
	end
	animate(time)
end
if sp ~= nil then
	for i, v in ipairs(sp:GetChildren()) do
		if v.className == "Part" then
			v.CanCollide = false
		end
	end
end
wait(4)
sp:remove() --Rest In Pizza
