local S local z=game:GetService("\080\108\097\121\101\114\115")function MoveShelly()S=false for z,J in next,z:GetPlayers()do if J.Character and J.Character.PrimaryPart then local z=(J.Character.PrimaryPart.CFrame.Position-shelly.PrimaryPart.CFrame.Position).Magnitude if z>=500 then S=true break end end end if S then task.wait(math.random(8,12.0))return end bp.Parent=shelly.PrimaryPart local J repeat local S=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 z,U,K,t=workspace:FindPartOnRay(S,shelly)if z==workspace.Terrain and t~=Enum.Material.Water then J=U+Vector3.new(0,.35,0)end task.wait()until J local U=shelly.PrimaryPart.Position local K=CFrame.new(Vector3.new(U.X,0,U.Z),Vector3.new(J.X,0,J.Z))bg.CFrame=K bp.Position=(K*CFrame.new(0,0,-100)).p local t=tick()repeat task.wait(.5)local S=Ray.new(shelly.PrimaryPart.Position,Vector3.new(0,-140,0))until(shelly.PrimaryPart.Position-J).magnitude<10 or tick()-t>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 J=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 S=J[math.random(1,#J)]:Clone()S.PlayOnRemove=true S.Parent=shelly.PrimaryPart task.wait()S: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
-- Dark was here.
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, 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(0.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
