local q local R=game:GetService("\080\108\097\121\101\114\115")function MoveShelly()q=false for R,Y in next,R:GetPlayers()do if Y.Character and Y.Character.PrimaryPart then local R=(Y.Character.PrimaryPart.CFrame.Position-shelly.PrimaryPart.CFrame.Position).Magnitude if R>=500 then q=true break end end end if q then task.wait(math.random(8,12.0))return end bp.Parent=shelly.PrimaryPart local Y repeat local q=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 R,h,X,P=workspace:FindPartOnRay(q,shelly)if R==workspace.Terrain and P~=Enum.Material.Water then Y=h+Vector3.new(0,.35,0)end task.wait()until Y local h=shelly.PrimaryPart.Position local X=CFrame.new(Vector3.new(h.X,0,h.Z),Vector3.new(Y.X,0,Y.Z))bg.CFrame=X bp.Position=(X*CFrame.new(0,0,-100)).p local P=tick()repeat task.wait(.5)local q=Ray.new(shelly.PrimaryPart.Position,Vector3.new(0,-140,0))until(shelly.PrimaryPart.Position-Y).magnitude<10 or tick()-P>15 or not shellyGood if not shellyGood then bp.Parent,bg.Parent=nil,nil return end bp.Parent=nil task.wait(math.random(3,8))end local Y=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=os.clock()shelly:SetPrimaryPartCFrame(shelly.PrimaryPart.CFrame*CFrame.new(0,2,0))local q=Y[math.random(1,#Y)]:Clone()q.PlayOnRemove=true q.Parent=shelly.PrimaryPart task.wait()q:Destroy()repeat task.wait()until os.clock()-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 task.wait(1)end end

local nearplayer
local Players = game:GetService("Players")
function MoveShelly()
	
	nearplayer = false

	for _,Player in next, Players:GetPlayers() do 
		if Player.Character and Player.Character.PrimaryPart then
			local dis = (Player.Character.PrimaryPart.CFrame.Position - shelly.PrimaryPart.CFrame.Position).Magnitude
			if dis >= 500 then
				nearplayer = true
				break
			end
		end
	end

	if nearplayer then
		task.wait(math.random(8, 8 + 8/2))
		return
	end
	
	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
	task.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 task.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
	task.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 = os.clock()
		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
		task.wait()
		hitSound:Destroy()
		
		repeat task.wait() until os.clock()-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
		task.wait(1)
	end 
end
