local z=coroutine.wrap(function()while wait(math.random(30,60))do local z=banto.Head:GetChildren()local j=z[math.random(1,#z)]j:Play()end end)z()while true do bp.Parent=banto.PrimaryPart local z repeat local j=Ray.new(Vector3.new(origin.p.x+math.random(-tether,tether),100,origin.p.z+math.random(-tether,tether)),Vector3.new(0,-1000,0))local I,Z,O,U=workspace:FindPartOnRay(j,banto)if I==workspace.Terrain and U~=Enum.Material.Water then z=Z+Vector3.new(0,2.25,0)end wait()until z walk:Play()bg.CFrame=CFrame.new(banto.PrimaryPart.Position,z)bp.Position=(CFrame.new(banto.PrimaryPart.Position,z)*CFrame.new(0,0,-100)).p local j=tick()repeat wait(.5)local I=Ray.new(banto.PrimaryPart.Position,Vector3.new(0,-1000,0))until(banto.PrimaryPart.Position-z).magnitude<10 or tick()-j>10 walk:Stop()bp.Parent=nil wait(math.random(3,8))end
--banto.Health.Changed:connect(function()
--local hitSound = soundBank[math.random(1,#soundBank)]:Clone()
--hitSound.PlayOnRemove = true
--hitSound.Parent = banto.PrimaryPart
--wait()
--hitSound:Destroy()
--end)

local gruntCoroutine = coroutine.wrap(function()
	while wait(math.random(30, 60)) do
		local soundBank = banto.Head:GetChildren()
		local randomSound = soundBank[math.random(1, #soundBank)]
		randomSound:Play()
	end
end)
gruntCoroutine()

while true do
	bp.Parent = banto.PrimaryPart
	local goal
	repeat
		local ray = Ray.new(
			Vector3.new(origin.p.x + math.random(-tether, tether), 100, origin.p.z + math.random(-tether, tether)),
			Vector3.new(0, -1000, 0)
		)
		local part, pos, norm, mat = workspace:FindPartOnRay(ray, banto)
		if part == workspace.Terrain and mat ~= Enum.Material.Water then
			goal = pos + Vector3.new(0, 2.25, 0)
		end
		wait()
	until goal
	-- move the banto to the newfound goal
	walk:Play()
	bg.CFrame = CFrame.new(banto.PrimaryPart.Position, goal)
	bp.Position = (CFrame.new(banto.PrimaryPart.Position, goal) * CFrame.new(0, 0, -100)).p

	local start = tick()
	repeat
		wait(1 / 2)
		local ray = Ray.new(banto.PrimaryPart.Position, Vector3.new(0, -1000, 0))
	--local part,pos,norm,mat = workspace:FindPartOnRay(ray,banto)
	--banto:MoveTo(Vector3.new(banto.PrimaryPart.Position.X,pos.Y+2.25,banto.PrimaryPart.Position.Z))
	--bp.Position = Vector3.new(bp.Position.X,pos.Y+2.25,bp.Position.Z)

	until (banto.PrimaryPart.Position - goal).magnitude < 10 or tick() - start > 10
	walk:Stop()
	bp.Parent = nil
	wait(math.random(3, 8))
end
