local d=script.Parent local l=d.PrimaryPart.CFrame local R=15 local z=d.PrimaryPart:WaitForChild("\066\111\100\121\071\121\114\111")local Q=d.PrimaryPart:WaitForChild("\066\111\100\121\080\111\115\105\116\105\111\110")Q.Position=l.p z.CFrame=d.PrimaryPart.CFrame local e=true local o=tick()function MoveShelly()Q.Parent=d.PrimaryPart local o repeat local z=Ray.new(Vector3.new(l.p.x+math.random(-R,R),d.PrimaryPart.Position.Y+100,l.p.z+math.random(-R,R)),Vector3.new(0,-130,0))local Q,e,Z,B=workspace:FindPartOnRay(z,d)if Q==workspace.Terrain and B~=Enum.Material.Water then o=e+Vector3.new(0,.35,0)end wait()until o local Z=d.PrimaryPart.Position local B=CFrame.new(Vector3.new(Z.X,0,Z.Z),Vector3.new(o.X,0,o.Z))z.CFrame=B Q.Position=(B*CFrame.new(0,0,-100)).p local O=tick()repeat wait(.5)local l=Ray.new(d.PrimaryPart.Position,Vector3.new(0,-140,0))until(d.PrimaryPart.Position-o).magnitude<10 or tick()-O>15 or not e if not e then Q.Parent,z.Parent=nil,nil return end Q.Parent=nil wait(math.random(3,8))end local Z=game.ServerStorage.Sounds.NPC.Shelly:GetChildren()d.Health.Changed:connect(function()if e then Q.Parent,z.Parent=nil,nil d.PrimaryPart.Transparency=1 d.PrimaryPart.CanCollide=false d.Shell.Transparency=1 d.HitShell.Transparency=0 d.HitShell.CanCollide=true e=false o=tick()d:SetPrimaryPartCFrame(d.PrimaryPart.CFrame*CFrame.new(0,2,0))local l=Z[math.random(1,#Z)]:Clone()l.PlayOnRemove=true l.Parent=d.PrimaryPart wait()l:Destroy()repeat wait()until tick()-o>10 d.PrimaryPart.Transparency=0 d.PrimaryPart.CanCollide=true d.Shell.Transparency=0 d.HitShell.Transparency=1 d.HitShell.CanCollide=false Q.Parent,z.Parent=d.PrimaryPart,d.PrimaryPart e=true end end)while true do if e then MoveShelly()else wait(1)end end

local shelly = script.Parent
local origin = shelly.PrimaryPart.CFrame
local tether = 15
local bg = shelly.PrimaryPart:WaitForChild'BodyGyro'
local bp = shelly.PrimaryPart:WaitForChild'BodyPosition'
bp.Position = origin.p
bg.CFrame = shelly.PrimaryPart.CFrame
local shellyGood = true
local ostrich = tick()

function MoveShelly()
	bp.Parent = shelly.PrimaryPart
	local goal
	repeat 
	local ray = Ray.new(Vector3.new(origin.p.x+math.random(-tether,tether), shelly.PrimaryPart.Position.Y+100, origin.p.z+math.random(-tether,tether)),Vector3.new(0,-130,0))
	local part,pos,norm,mat = workspace:FindPartOnRay(ray, shelly)
	if part == workspace.Terrain and mat ~= Enum.Material.Water then
		goal = pos+Vector3.new(0,.35,0)
	end
	wait()
	until goal
	--Set new goal for banto to MoveTo :)
	local pos = shelly.PrimaryPart.Position
	local cf = CFrame.new(Vector3.new(pos.X, 0, pos.Z), Vector3.new(goal.X, 0, goal.Z))
	bg.CFrame = cf
	bp.Position = (cf*CFrame.new(0,0,-100)).p
	
	local start = tick()
	repeat wait(.5)
	local ray = Ray.new(shelly.PrimaryPart.Position, Vector3.new(0,-140,0))
	
	until (shelly.PrimaryPart.Position-goal).magnitude < 10 or tick()-start >15 or not shellyGood
	if not shellyGood then bp.Parent,bg.Parent= nil,nil return end
	bp.Parent = nil
	wait(math.random(3,8))
end


local soundBank = game.ServerStorage.Sounds.NPC.Shelly:GetChildren()
shelly.Health.Changed:connect(function()
	if shellyGood then
		bp.Parent,bg.Parent= nil,nil
		shelly.PrimaryPart.Transparency =1
		shelly.PrimaryPart.CanCollide = false
		shelly.Shell.Transparency = 1
		shelly.HitShell.Transparency = 0
		shelly.HitShell.CanCollide = true
		shellyGood = false
		ostrich = tick()
		shelly:SetPrimaryPartCFrame(shelly.PrimaryPart.CFrame*CFrame.new(0,2,0))
		local hitSound = soundBank[math.random(1,#soundBank)]:Clone()
		hitSound.PlayOnRemove = true
		hitSound.Parent = shelly.PrimaryPart
		wait()
		hitSound:Destroy()
		
		repeat wait() until tick()-ostrich > 10
		shelly.PrimaryPart.Transparency = 0
		shelly.PrimaryPart.CanCollide = true
		shelly.Shell.Transparency = 0
		shelly.HitShell.Transparency = 1
		shelly.HitShell.CanCollide = false
		bp.Parent,bg.Parent = shelly.PrimaryPart,shelly.PrimaryPart
		shellyGood = true
	end
end)

while true do
	if shellyGood then
		MoveShelly()
	else
		wait(1)
	end 
end
